Hacker News new | past | comments | ask | show | jobs | submit login

> But once you've got "//go:generate", adding "//go:embed" isn't really any worse.

There's way more than that: https://golang.org/src/cmd/compile/internal/gc/lex.go#L53

And I would argue that it's bull. Once they realised that they were introducing pragmas / attributes into the language, they should have bitten the bullet and actually introduced a clean way to annotate language items.

The first and second ones are excusable as "we'll only need one" and "well it's not worth the hassle" but at the third one it's not a special case it's a pattern. Especially as the excuse that "other implementations can ignore those" gets less and less true: a compiler which ignores go:embed can not be considered working.




Wow, the lexer function is even named "pragmaValue". So Go does have a concept of pragma, not just magic comments. Go developers' stubbornness on forward compatibility is beyond me.


To quote[1] Russ Cox: "C uses #pragma foo for this. Go simply spells #pragma as //go:."

https://www.reddit.com/r/golang/comments/hv96ny/qa_goembed_d...




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: