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: exclude $GOPATH/src/mod from “all” and “...” patterns in GOPATH mode #26401

Closed
bcmills opened this issue Jul 16, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@bcmills
Copy link
Member

commented Jul 16, 2018

After performing a go build in module mode, go build all in GOPATH mode emits a bunch of errors due to import path mismatches in $GOPATH/src/mod.

Since the code in $GOPATH/src/mod isn't intended to be buildable in GOPATH mode in the first place, we should explicitly ignore it.

~/src$ cd $GOPATH/src

~/src$ go get rsc.io/sampler

~/src$ pushd rsc.io/sampler
~/src/rsc.io/sampler ~/src

~/src/rsc.io/sampler$ GO111MODULE=on go build .
go: finding golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c

~/src/rsc.io/sampler$ popd
~/src

~/src$ GO111MODULE=off go build all 2>&1 | grep mod/ | head -n 10
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cases: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cases"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cmd/gotext: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cmd/gotext"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/build: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/build"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/tools/colcmp: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/tools/colcmp"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/currency: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/currency"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/charmap: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/charmap"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/htmlindex: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/htmlindex"

(CC: @rsc)

@bcmills bcmills added this to the Go1.11 milestone Jul 16, 2018

@bcmills bcmills changed the title cmd/go: exclude $GOPATH/src/mod from “all” pattern in GOPATH mode cmd/go: exclude $GOPATH/src/mod from “all” and “...” patterns in GOPATH mode Jul 16, 2018

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 17, 2018

Yes, mod should just be invisible in GOPATH/src. That's in internal/search I think.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 17, 2018

We could plausibly backport the GOPATH/src/mod exclusion to Go 1.9 and Go 1.10 as well.

@gopherbot

This comment has been minimized.

Copy link

commented Jul 24, 2018

Change https://golang.org/cl/125675 mentions this issue: cmd/go: exclude import paths beginning with mod/ from patterns

@anacrolix

This comment has been minimized.

Copy link
Contributor

commented Jul 25, 2018

Any reason this stuff can't go in $GOPATH/mod or something other than $GOPATH/src? I posted to golang-dev just now on this.

@davecheney

This comment has been minimized.

Copy link
Contributor

commented Jul 25, 2018

@anacrolix

This comment has been minimized.

Copy link
Contributor

commented Jul 25, 2018

How do those people setting $GOPATH=$HOME rationalize pkg? .mod seems good if the existing tools work with that.

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Jul 25, 2018

How do those people setting $GOPATH=$HOME rationalize pkg?

I mostly close my eyes and pretend it isn't there. (And soon it won't be! See #4719.)

@anacrolix

This comment has been minimized.

Copy link
Contributor

commented Jul 26, 2018

Regarding the CL: It would be nice if "mod" was a constant somewhere. Similarly for its use elsewhere in the code base.

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Jul 30, 2018

On hold pending a decision on whether to move the module cache someplace where it would be ignored by default (outside of $GOPATH/src or in a subdirectory beginning with . or _).

@bcmills bcmills self-assigned this Jul 30, 2018

@gopherbot

This comment has been minimized.

Copy link

commented Jul 30, 2018

Change https://golang.org/cl/126755 mentions this issue: cmd/go: move module cache from $GOPATH/src/mod to $GOPATH/pkg/mod

@gopherbot gopherbot closed this in b8f42d7 Aug 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.