3 ms·
You might be right, this is the best solution in Go at this moment, but that's a local optimum. You don't have to solve this kind of problems in many other lang
by junke 11y ago
You might be right, this is the best solution in Go at this moment, but that's a local optimum. You don't have to solve this kind of problems in many other languages.
The generator given as an example in the official blog [0] is called "stringer". It is made of 639 lines [1] mixing ast parsing/traversing and printf statements. If this is what I am supposed to write then of course copy-pasting becomes a pragmatic alternative.
[0] https://blog.golang.org/generate https://blog.golang.org/generate
[1] https://raw.githubusercontent.com/golang/tools/master/cmd/stringer/stringer.go https://raw.githubusercontent.com/golang/tools/master/cmd/st...