go: go/build: commas in build tag lists should error
I just realised that multiple build tags are separated by spaces, not commas. I had been doing go install -tags 'foo,bar'
instead of go install -tags 'foo bar'
for days without noticing, because the former meant a single build tag that did nothing at all.
Two other people in my team went through the very same issue weeks ago when learning build tags, so surely it’s not just my misunderstanding.
I suggest that we either make the docs clearer about this (edit: done by @ALTree below), or that we make commas illegal in build tags so that -tags 'foo,bar'
would error instead of silently ignoring both tags.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 19 (17 by maintainers)
Commits related to this issue
- cmd/go: clarify that tag lists are space-separated Apparently the current documentation is confusing users that quickly skim the flags list at the top. Make very clear that build tags are space-separ... — committed to golang/go by ALTree 7 years ago
- cmd/go: change -tags to a comma-separated list Using commas makes it possible to put multiple tags into GOFLAGS. The space-separated form is still recognized and will be maintained. Alleviates #2684... — committed to golang/go by rsc 5 years ago
I agree with mvdan, what I understand when I read
-tags 'tag list'
is thattags
takes the usual comma-separated list. I could expect the command to also accept space-separated values, but I would be surprised to see that a comma-separated list is actually rejected.Slightly better would be:
-tags 'tag1 tag2'
.Even better: clarify it using English words in the following description: “… accepts a space separated list of tags …”
If the ‘go’ help says it accepts a space-separated list, I would prefer that it error on any commas rather than silently converting it to spaces. Otherwise the help should be changed to “space and/or comma separated”, which I would find unnecessarily confusing.
Does anyone disagree with commas in build tags erroring? If noone speaks up in the next week, I’ll work on a patch. Not sure if this is soon enough to get into 1.9, though.