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: support -mod=vendor and -mod=readonly together #30404

reefbarman opened this issue Feb 26, 2019 · 2 comments

cmd/go: support -mod=vendor and -mod=readonly together #30404

reefbarman opened this issue Feb 26, 2019 · 2 comments


Copy link

@reefbarman reefbarman commented Feb 26, 2019

What version of Go are you using (go version)?

$ go version
go version go1.11.5 windows/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\\Go
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set GOMOD=C:\\\services\\go.mod
set CGO_CFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\\AppData\Local\Temp\go-build195410922=/tmp/go-build -gno-record-gcc-switches

What did you do?

$ go build -mod=vendor -mod=readonly

What did you expect to see?

go build both using the vendor directory and respecting the readonly aspect of not modifying the go.mod file

What did you see instead?

go build not using vendoring

Basically in a CI pipeline I want the build to ensure the go.mod file is correct are represent the right dependencies while also download dependencies to the vendor directory so the CI pipeline can cache the download for the next run


This comment has been minimized.

Copy link

@mvdan mvdan commented Feb 26, 2019

#30240 will allow automatic vendoring in module mode, so I presume you'll be able to drop -mod=vendor and still use the vendor folder. /cc @bcmills

@bcmills bcmills changed the title Support -mod=vendor and -mod=readonly together cmd/go: support -mod=vendor and -mod=readonly together Feb 27, 2019

This comment has been minimized.

Copy link

@bcmills bcmills commented Feb 27, 2019

Semantically, -mod=readonly means “resolve module imports, but fail if they must be reconfigured”, while -mod=vendor means “resolve module imports only from the vendor directory”. There is no well-defined combination of those two meanings, since -mod=vendor already implies that we cannot modify the build list.

#30240, if accepted, will make -mod=readonly by itself use the vendor directory if present. I suspect that it will address your entire use-case, so I'm going to close this issue as a duplicate of that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.