News for hackers. Stuff that matters.
Re:Show HN: Gojay – Performant JSON encoder/decoder for Golang by Vendan on Sunday May 20, 2018 @01:24PM (#17113807)
Having written a data serialization library based on codegen, I would have to say that Go is relatively simple to codegen. One big annoyance is the import system of "if you don't need it, it's an error to import it.", which, while simple enough for manual code, means you have to do extra work while generating code to keep track of what you actually use (i.e. if none of the things are a time.Time, you don't need to import "time"). The other approach is to use stuff like "var _ = time.Now" kind of constructs, which do make the codegen easier, but I personally feel are far dirtier.

One very nice feature of go is that the formatter is available as a library (https://golang.org/pkg/go/format/#Source), so you can gen "raw" code and then throw it through the formatter to get nice pretty output.

Re:Show HN: Gojay – Performant JSON encoder/decoder for Golang by dullgiulio on Sunday May 20, 2018 @01:56PM (#17113958)
Unused imports are definitely not an unsolved problem: as last step after dumbly generating code, run goimports.
Re:Show HN: Gojay – Performant JSON encoder/decoder for Golang by Vendan on Sunday May 20, 2018 @02:19PM (#17114063)
Never said "unsolved", I said "annoyance". And I tend to write the code to figure it out and do the right thing. My annoyance is with code gens that do https://github.com/golang/protobuf/blob/master/protoc-gen-go.... Not even goimports will strip those...