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

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

bcmills opened this issue Nov 25, 2019 · 2 comments
Assignees
Milestone

Comments

@bcmills
Copy link
Member

@bcmills 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 this to the Go1.14 milestone Nov 25, 2019
@bcmills bcmills self-assigned this Nov 25, 2019
@bcmills bcmills added the modules label Nov 25, 2019
@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Nov 26, 2019

I believe this is a duplicate of #32471.

@bcmills

This comment has been minimized.

Copy link
Member Author

@bcmills 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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.