logoalt Hacker News

omoikaneyesterday at 9:41 PM3 repliesview on HN

I wonder why they chose to add these directives as comments as opposed to adding new syntax for them. It feels like a kludge.

https://wiki.c2.com/?HotComments


Replies

kjksfyesterday at 9:59 PM

Go designers distinguish between Go language as defined by Go spec and implementation details.

//go:fix is something understood by a particular implementation of Go. Another implementation could implement Go without implementing support for //go:fix and it would be a fully compliant implementation of Go, the language.

If they made it part of the syntax, that would require other implementations to implement it.

show 2 replies
Groxxyesterday at 11:41 PM

Because these are instructions for users for making tool-assisted changes to their source code, not a behavior that exists at runtime (or even compile time). A new syntax wouldn't make sense for it.

For other things, like `//go:noinline`, this is fair criticism. `//go:fix inline` is quite different in every way.

0x696C6961yesterday at 9:48 PM

The //go:xyz comments are an established pattern in the Go tooling.

show 1 reply