Go version
go1.23.10
Output of go env
in your module/workspace:
GO111MODULE='ON'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/acedus/.cache/go-build'
GOENV='/home/acedus/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/acedus/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/acedus/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.10'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/acedus/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/acedus/dev/repos/kubevirt/go.mod'
GOWORK='/home/acedus/dev/repos/kubevirt/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3009368656=/tmp/go-build -gno-record-gcc-switches'
What did you do?
Running go clean -mod=vendor
in conjunction with go workspaces fails due to inconsistent vendoring despite having run go work vendor
.
It appears that go clean
doesn't call modload.InitWorkfile
which in turn causes the command to be oblivious to workspaces. Adding modload.InitWorkfile
to runClean
fixes the issue.
What did you see happen?
go clean -mod=vendor
go: inconsistent vendoring in /home/acedus/dev/repos/kubevirt:
kubevirt.io/api: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
kubevirt.io/client-go: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
To ignore the vendor directory, use -mod=readonly or -mod=mod.
To sync the vendor directory, run:
go mod vendor
What did you expect to see?
go clean -mod=vendor
should succeed when used in conjunction with go workspaces.
Comment From: gabyhelp
Related Issues
- cmd/go: default `-mod=vendor` behavior unexpectedly present in workspace mode #54130 (closed)
- cmd/go: go mod vendor ignore workspace #54452 (closed)
- cmd/go: work sync and mod vendor don't use other main modules in workspace #53904 (closed)
- cmd/go: support vendoring in workspace mode #60056 (closed)
- cmd/go: 1.18 fails when vendoring and main module replaces itself #51285 (closed)
- cmd/go: exclude vendor directories when using `go work use -r .` #51710
- proposal: cmd/go: add way to force ignoring vendor directory #39247 (closed)
- go build not use vendor package in 1.13.5 #38640 (closed)
- cmd/go: bad error message when using `vendor` directory while specifying too old Go version #67587 (closed)
- Proposal: Respect the vendor folder is one exits. #34371 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: gopherbot
Change https://go.dev/cl/682856 mentions this issue: cmd/go: clean should respect workspaces
Comment From: dmitshur
CC @golang/command-line.