News for hackers. Stuff that matters.
Re:Learn Go in five minutes by grey-area on Tuesday January 05, 2021 @01:27PM (#25648959)
The Go authors have (ab)used comments to extend the language in experimental ways for code generation, build pragmas and recently file embedding.

They’ve done this to avoid breaking the language stability guarantee, not sure if there were other reasons. I think it’s a mistake personally to create this sort of metalanguage in comments (now you have two problems!) but it’s easy to avoid using this most of the time as the uses are pretty esoteric.

Re:Learn Go in five minutes by skrtskrt on Tuesday January 05, 2021 @02:35PM (#25649923)
File embedding is a common enough use case (HTML templates, config files) that it really makes me cringe that it's being done with comments.
Re:Learn Go in five minutes by grey-area on Tuesday January 05, 2021 @03:49PM (#25650820)
I just keep my templates and config in separate files.

There are good reasons to keep them separate anyway (allows config without recompile for example) and for the apps I work on distribution isn’t a problem. So I haven’t really had to use comments as code in 7-8 years of go. Perhaps it’ll become more common with the embed stuff. But then I don’t use struct tags either so I guess I’d prefer Go to be even simpler.