Skip to content
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

cmd/go: 'go test -mod=mod' fails if GOFLAGS contains a default -mod setting #35827

Closed
bcmills opened this issue Nov 25, 2019 · 2 comments
Closed
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Nov 25, 2019

go test -mod=mod does not successfully override a -mod flag specified in GOFLAGS.
Instead, it fails with go test: mod flag may be set only once.

go version devel +bb87c192f9 Mon Nov 25 11:43:42 2019 -0500 linux/amd64

Script test to reproduce:

env GO111MODULE=on
env GOFLAGS=-mod=readonly
go list -mod=mod all
go test -mod=mod .

-- go.mod --
module example.com

go 1.14

require rsc.io/quote latest
-- foo_test.go --
package foo

Output:

--- FAIL: TestScript (0.01s)
    --- FAIL: TestScript/mod_goflags (0.07s)
        script_test.go:193:
            # An explicit -mod= flag should override one set via GOFLAGS. (0.056s)
            > env GOFLAGS=-mod=readonly
            > go list -mod=mod all
            [stdout]
            example.com
            > go test -mod=mod .
            [stderr]
            go test: mod flag may be set only once
            run "go help test" or "go help testflag" for more information
            [exit status 2]
            FAIL: testdata/script/mod_goflags.txt:7: unexpected command failure

CC @jayconrod

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 25, 2019
@bcmills bcmills added this to the Go1.14 milestone Nov 25, 2019
@bcmills bcmills self-assigned this Nov 25, 2019
@agnivade
Copy link
Contributor

I believe this is a duplicate of #32471.

@bcmills
Copy link
Contributor Author

bcmills commented Nov 26, 2019

@agnivade, thanks for the reference. I had overlooked it because vet is not implicated in this path.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants