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

Most upvoted comments

I agree with mvdan, what I understand when I read -tags 'tag list' is that tags 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.