quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

Go: prepend struct field comment (support GoDoc)

Open cv opened this issue 5 years ago • 1 comments

This makes the Go generator prepend struct field comments, so instead of:

type Bar struct {
  Foo string `json:"foo"` // this bar's foo
}

...we get:

type Bar struct {
  // this bar's foo
  Foo string `json:"foo"`
}

...which GoDoc supports and documents accordingly.

cv avatar Sep 02 '20 15:09 cv

Bump for this to get merged..

bruth avatar Jun 24 '21 11:06 bruth

@cv thank you! There is a small build error.

dvdsgl avatar Jan 03 '23 18:01 dvdsgl

Including the comments in the column formatting produces code that gofmt does not like:

CleanShot 2023-01-03 at 11 29 00@2x

gofmt does:

CleanShot 2023-01-03 at 11 29 45@2x

dvdsgl avatar Jan 03 '23 19:01 dvdsgl

@dvdsgl is the expectation that the code generated by the tool passes gofmt without change?

In some of our projects that involve Go code generation we've been successful so far with letting the generator make a bit of a mess, then let gofmt clean everything up later.

cv avatar Jan 03 '23 20:01 cv