You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
amd64
darwin
What did you do?
As an example, a build tag like // +build unit, !integration, !component will produce unexpected results when running tests. Running go vet does not warn about this type of ill-formed build constraint.
Example
Given the enclosed files:
unit_test.go
// +build unit, !component, !integrationpackage test
import"fmt"funcinit() {
fmt.Println("unit test")
}
// +build integration, !unit, !componentpackage test
import"fmt"funcinit() {
fmt.Println("integration")
}
Running go test ./... -tags unit -v produces:
component test
integration
unit test
While running go test ./... -tags component -v produces:
component test
unit test
And running go test ./... -tags integration -v produces:
integration test
What did you expect to see?
While this conditional syntax is incorrect, the produced output is confusing and running go vet should warn about combining AND immediately followed by OR (i.e. , ). Updating build tags to // +build unit,!integration,!component leads to expected behavior but it would be helpful for go vet to catch and warn about using commas followed by a space in build tags.
What did you see instead?
Running go vet doesn't indicate any issues.
The text was updated successfully, but these errors were encountered:
We are in the process of moving from +build constraints to go:build constraints, which is intended to fix problems like this. See #41184. I think that will address this problem.
seankhliao
changed the title
proposal: cmd/vet warn unexpected behavior from
proposal: cmd/vet warn about malformed build constraints
Jan 21, 2021
(@peter-crist If that answer is fully satisfactory please feel free to retract this proposal. Otherwise it can go through the usual proposal review process. Thanks.)
ianlancetaylor
changed the title
proposal: cmd/vet warn about malformed build constraints
proposal: cmd/vet: warn about malformed build constraints
Jan 26, 2021
(@peter-crist If that answer is fully satisfactory please feel free to retract this proposal. Otherwise it can go through the usual proposal review process. Thanks.)
Closing as that should address the issue at hand. Thank you.
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
As an example, a build tag like
// +build unit, !integration, !component
will produce unexpected results when running tests. Runninggo vet
does not warn about this type of ill-formed build constraint.Example
Given the enclosed files:
unit_test.go
component_test.go
integration_test.go
Running
go test ./... -tags unit -v
produces:While running
go test ./... -tags component -v
produces:And running
go test ./... -tags integration -v
produces:What did you expect to see?
While this conditional syntax is incorrect, the produced output is confusing and running
go vet
should warn about combiningAND
immediately followed byOR
(i.e.,
). Updating build tags to// +build unit,!integration,!component
leads to expected behavior but it would be helpful forgo vet
to catch and warn about using commas followed by a space in build tags.What did you see instead?
Running
go vet
doesn't indicate any issues.The text was updated successfully, but these errors were encountered: