The documentation implies that workspace mode and vendoring are incompatible:
By default, if the go version in go.mod is 1.14 or higher and a vendor directory is present, the go command acts as if -mod=vendor were used. from Go Modules Reference
A manual run of go build -mod=vendor produces an error:
go: -mod may only be set to readonly when in workspace mode, but it is set to "vendor"
Remove the -mod flag to use the default readonly value,
or set GOWORK=off to disable workspace mode.
Module vendoring is ignored in workspace mode because it is not clear which modules' vendor directories should be respected if there are multiple workpace modules with vendor directories containing the same dependencies.
What did you see instead?
$ go build
$ ./my_workspace
Fake library is used
Explicitly specifying -mod=readonly (which theoretically is the only option value compatible with workspace mode):
$ go build -mod=readonly
$ ./my_workspace
Testphrase
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (also reproduces on 1.18.4)
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go.work
file andvendor
directory containing a fake librarygo build
, and then./my_workspace
What did you expect to see?
The documentation implies that workspace mode and vendoring are incompatible:
By default, if the go version in go.mod is 1.14 or higher and a vendor directory is present, the go command acts as if -mod=vendor were used.
from Go Modules Referencego build -mod=vendor
produces an error:The original workspace proposal explicitly stated that vendoring is ignored in workspace mode:
What did you see instead?
Explicitly specifying
-mod=readonly
(which theoretically is the only option value compatible with workspace mode):The text was updated successfully, but these errors were encountered: