Hi Folks,

The documentation of build constraints <https://golang.org/pkg/go/build/> 
says, in part (emphasis mine):

Constraints may appear in any kind of source file (not just Go), but they 
> must appear near the top of the file, *preceded only by blank lines and 
> other line comments*.


The current implementation 
<https://github.com/golang/tools/blob/99f201b6807eb28f750a1966316bb0d4417b6020/go/analysis/passes/buildtag/buildtag.go#L45>
 (and 
presumably all past implementations) explicitly enforces the constraint 
that a preceding general (i.e. non-line) comment is not permitted.

Does anyone remember the rationale for that?  Something to do with avoiding 
undesired coincidental matching of comments in non-Go files?  I've done a 
little forensic digging, but it quickly gets tricky as the code originated 
in cmd/vet.

I ran across this recently when attempting to insert a build constraint 
into some of our existing Go code with a boilerplate corporate copyright 
which started life in C/C++ source files.  It took me quite a while to 
figure out what was going on....  :-)

Regards,
Neil

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d4626304-c167-4c5b-a408-1a46a736f0ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to