-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go/build: commas in build tag lists should error #18800
Comments
It seems to be documented properly.
Note, it's |
I realise that - but even though we all read that line, we still used commas. Note that lists are usually comma-separated, and |
Does vet complain about this? If not, perhaps it should. There is already a build tags check. |
@josharian what go vet command, exactly? I can't get it to complain. Given the documentation tag added, I assume being more explicit in the docs is preferred. Either of the two fixes sounds fine by me, but a check would be nice. |
@josharian This is, I believe, about a command option tag list, not about source code.
@mvdan Well, if the documentation shows a description/descriptive example, I wonder what the documentation is missing. |
What I said above is that I don't see the help line as an example. Sure it's a description, but definitely not an example since |
I agree with mvdan, what I understand when I read Slightly better would be: Even better: clarify it using English words in the following description: "... accepts a space separated list of tags ..." |
@ALTree thanks for the suggestions, those sound more self-explanatory. |
Haha, indeed. Given that no build tag could ever include a comma, maybe cmd/go could fail with an error when given a tags flag containing a comma. We should fix the docs too, of course. |
CL https://golang.org/cl/35951 mentions this issue. |
Even though I'm happy with the doc fix CL above, I'd still like to see the go tools error if commas appear in space-separated lists. @josharian said they aren't allowed as tags, so at least for that option it makes sense. |
@mvdan sure I'll change the CL from I think you'll have to maybe change the issue title (and remove the |
@ALTree I didn't add the error directly in the title because I wasn't sure it would be possible (maybe commas were valid parts of a build tag), and because I thought the documentation bit was more important to fix first. Since you're talking care of that, I'll update the issue. Thanks! |
Apparently the current documentation is confusing users that quickly skim the flags list at the top. Make very clear that build tags are space-separated. Updates #18800 Change-Id: I473552c5a2b70ca03d8bbbd2c76805f7f82b49a2 Reviewed-on: https://go-review.googlesource.com/35951 Reviewed-by: Daniel Martí <[email protected]> Reviewed-by: Minux Ma <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
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. |
Would it harm anything if |
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. |
If you mail the CL before May 1, it can at least be considered for 1.9
I concur. |
Thanks - will try to get a patch ready by tomorrow then. Anyone strongly against it can speak up there instead. |
CL https://golang.org/cl/41951 mentions this issue. |
Using commas makes it possible to put multiple tags into GOFLAGS. The space-separated form is still recognized and will be maintained. Alleviates #26849 somewhat. Fixes #18800 (again). Change-Id: I6f4cf28ea31e53e21ccbdad6ef1a0aee63b007d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/173438 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
I just realised that multiple build tags are separated by spaces, not commas. I had been doing
go install -tags 'foo,bar'
instead ofgo 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.The text was updated successfully, but these errors were encountered: