New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(spanner): fix layout of godoc for Encoder and Decoder #4128
fix(spanner): fix layout of godoc for Encoder and Decoder #4128
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the fix!
// Prefix string | ||
// Suffix string | ||
// } | ||
// type customField struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It would be nice to turn these into a first class godoc example. Here is an example from the storage library:
- Godoc: https://pkg.go.dev/cloud.google.com/go/storage#example-ACLHandle.Delete
- Code:
google-cloud-go/storage/example_test.go
Lines 527 to 537 in a5bbdb5
func ExampleACLHandle_Delete() { ctx := context.Background() client, err := storage.NewClient(ctx) if err != nil { // TODO: handle error. } // No longer grant access to the bucket to everyone on the Internet. if err := client.Bucket("my-bucket").ACL().Delete(ctx, storage.AllUsers); err != nil { // TODO: handle error. } }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is a good case for that. There are two reasons to put in this way:
- The first class godoc example seems to be a main function to guide users how to use the api. Here we just want to show how to implement the interfaces.
- The example can be close to the code. Probably better in the comment instead of jumping to another file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion! This example contains a type definition and method definition, so if I understand correctly, we need a separate file to turn this into first class godoc example.
For example, sort package has a similar example for Example (SortWrapper) by this code. I'm wondering if I should do similar thing for this example.
I'll merge this in first. We can improve the doc later if necessary. |
Fix: #4127
I added an additional indent to code sample to fix the layout issue for Encoder/Decoder.
This is a screenshot for the godoc for the fixed code (I used the
godoc
command to check the fix, so the style of godoc is an old one):