You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
GOARCH=amd64
GOHOSTARCH=amd64
GOHOSTOS=windows
What did you do?
I have a local project outside of my GOPATH that consumes packages from another related local project, also outside of GOPATH.
/proj1/somepkg
/proj2/
proj2's go.mod redirects the package path: replace example.com/proj1 => ../proj1
This builds perfectly using go build - but if I want to do vendored builds, using go mod vendor copies contents of proj1/somepkg into proj2/vendor/example.com/proj1/somepkg/.
What did you expect to see?
Since proj1 and proj2 are both local code, and Go Modules are meant to facilitate local code outside of a GOPATH, I had hoped local code could be left in place - then go build -mod=vendor would use a combination of the go.mod require/replace specs to build with local code requirements and vendored external package requirements.
What did you see instead?
go build -mod=vendor seems to make the logical assumption that all imported external modules are under the vendor/ subdirectory. It seems to be a binary choice - either all vendored or all versioned modules.
This makes sense to me. I understand this design choice and the need for compatibility with dep. But for the sake of local code, it would be nice to have total control over where the vendored module requirements are found.
As a (failed) workaround I tried using go mod vendor to collect dependencies, removed my copied source, added a replace for all external dependencies with the vendored path in go.mod, and go build normally. However, Go Modules isn't happy:
go: parsing vendor\github.com\google\gops\go.mod: open <path>proj2\vendor\github.com\google\gops\go.mod: The system cannot find the file specified.
go: parsing vendor\github.com\globalsign\mgo\go.mod: open <path>proj2\vendor\github.com\globalsign\mgo\go.mod: The system cannot find the file specified.
go: error loading module requirements
The text was updated successfully, but these errors were encountered:
for the sake of local code, it would be nice to have total control over where the vendored module requirements are found.
I don't think you'll ever have “total control” short of managing an ungainly number of replace directives, but I think your use-case is more or less #27542. It's not obvious to me whether the solution should build on the existing vendor support or not.
What version of Go are you using (
go version
)?go1.11 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
I have a local project outside of my GOPATH that consumes packages from another related local project, also outside of GOPATH.
proj2's
go.mod
redirects the package path:replace example.com/proj1 => ../proj1
This builds perfectly using
go build
- but if I want to do vendored builds, usinggo mod vendor
copies contents ofproj1/somepkg
intoproj2/vendor/example.com/proj1/somepkg/
.What did you expect to see?
Since
proj1
andproj2
are both local code, and Go Modules are meant to facilitate local code outside of a GOPATH, I had hoped local code could be left in place - thengo build -mod=vendor
would use a combination of the go.mod require/replace specs to build with local code requirements and vendored external package requirements.What did you see instead?
go build -mod=vendor
seems to make the logical assumption that all imported external modules are under thevendor/
subdirectory. It seems to be a binary choice - either all vendored or all versioned modules.This makes sense to me. I understand this design choice and the need for compatibility with
dep
. But for the sake of local code, it would be nice to have total control over where the vendored module requirements are found.As a (failed) workaround I tried using
go mod vendor
to collect dependencies, removed my copied source, added areplace
for all external dependencies with the vendored path ingo.mod
, andgo build
normally. However, Go Modules isn't happy:The text was updated successfully, but these errors were encountered: