3 ms·
I guess the meta programming that most often gets used with //go:generate ends up being text/template. The Go sort algorithm (pdqsort) is implemented in this w
by ncruces 2y ago
I guess the meta programming that most often gets used with //go:generate ends up being text/template.
The Go sort algorithm (pdqsort) is implemented in this way so the same algorithm can be used to implement the various existing sort APIs.
https://github.com/golang/go/blob/master/src/sort/gen_sort_variants.go https://github.com/golang/go/blob/master/src/sort/gen_sort_v...
- jerf 2y ago100% of the work is done by the code that go:generate invokes, though. Literally 100%. go:generate brings nothing to the table, except like I said some env variables. You can simply directly invoke the thing go:generate invokes and it will work fine, because go:generate does nothing to help with code generation. I've used go:generate once, and what my invocation did was extract a swagger file from the code. Because it doesn't matter what go:generate runs. You can make it so go:generate will run a shutdown command, or deploy your code, or start up Skyrim. 'Tis a strange "macro language" that will start Skyrim exactly as happily as it will "macro". And I pulled it out because it was easier to just run the code directly.