| ||Go Lang: Comments Are Not Directives|
279 points by Merkur on May 11, 2015 | hide | past | favorite | 219 comments |
|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:
# used to generate code:
# used to document the result of a example function:
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
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.
| Apply to YC