3 ms·
The implementation of this is pretty interesting, in that it generates code that imports your code, compiles it, and then uses reflection to generate the serial
by hannibalhorn 13y ago
The implementation of this is pretty interesting, in that it generates code that imports your code, compiles it, and then uses reflection to generate the serialization code. And in the end, that worked out better for the author than using the AST.
- lucian1900 13y agoIf anything, that would be an indication that the tooling is nowhere near good enough. Any reflection should be doable entirely with data the compiler has anyway.
- timtadh 13y agoActually there is a tool for this. I think the author was simply un-aware of it. It is called oracle* and is able to answer this typing question and many more. *: https://code.google.com/p/go/source/browse/cmd/oracle/main.go?repo=tools https://code.google.com/p/go/source/browse/cmd/oracle/main.g...
- hierro 13y agoThe tooling is excellent, but the author wasn't aware of it. In fact, the stdlib and the go.types repository provide almost anything required to write a front-end for a Go compiler.