Go 1.4 starts to use comments as directives. I think that is a realy bad path to go on the long run. You see its beginnings in following 3 examples:
# used to set a canonical import path for a package:
//import "foo"
# used to generate code:
//go:generate bar
# used to document the result of a example function:
//Output: foo
Comments should not be directives. Comments are free form, they do not have a syntax (as demonstrated in the examples). Comments are for humans - programms should ignore them or threat them as - comments!
It is my optinion that if Go needs some kind of annotation, than there should be a new syntax for it.
I would propose that directives to the tool chain will be marked with
#TAG: DIRECTIVE
a tool would be able to register the TAG with the go build environment. If a TAG is found in the code - the tool is called to do what ever needs to be done.
In go 1.4, save the following to a file and run 'go generate' on it: https://play.golang.org/p/9WJtxClRXr (I'd make it run in the playground, but you can't 'fork exec', so exec.Command($GOBIN, generate) won't work sadly)
Even though that code has no comments (only a multi-line string), go generate will run and print out a '\'.
I also used that generate command to point out that with generate, as it exists in 1.4, there's actually NO WAY to print out a dollar sign.
The dollar-sign part of this is fixed in master (so go1.5), but it was fixed not by allowing '\$', but by the bizarre $DOLLAR environment variable. See https://go-review.googlesource.com/#/c/8091/
These "features" make the use of comments as directives even worse, because it's NOT comments being used as directives in the case of go generate, but simple string matching. It literally just loops through lines of text and checks if it startswith the correct substring.
This was, of course, done due to lazyness (same as $DOLLAR and many other 'features' of go), and the lazyness is starting to show through the cracks here and there.
Go often prefers pain for the programmer for the compiler developer's life being simpler by about 5 minutes.