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

x/tools/refactor/importgraph: running tests with GO111MODULE=on is slow and writes to GOPATH workspace #30221

dmitshur opened this issue Feb 14, 2019 · 0 comments


Copy link

commented Feb 14, 2019

Can be reproduced using Go 1.11.5 on macOS:

$ ls /tmp/gopath
ls: /tmp/gopath: No such file or directory
$ export GOPATH=/tmp/gopath
$ go get
$ go get
$ shasum /tmp/gopath/src/
965892713fd48f7842527e54e9a8d63639d8afe4  /tmp/gopath/src/
$ cd /tmp/gopath/src/

importgraph $ GO111MODULE=off go test -count=1
ok	0.337s
importgraph $ shasum /tmp/gopath/src/
965892713fd48f7842527e54e9a8d63639d8afe4  /tmp/gopath/src/

importgraph $ GO111MODULE=on go test -count=1
go: creating new go.mod: module
ok	25.369s
importgraph $ shasum /tmp/gopath/src/
3bf82fbc8cf4b6b2366a5d87ab990a94af8bc1e4  /tmp/gopath/src/

Running importgraph tests in module mode should not make modifications inside the user's GOPATH workspace. Fortunately, it only modifies go.mod and go.sum files, which is easy to revert thanks to version control systems.

It also makes the test very slow when one's GOPATH is sizable. With my real GOPATH, it was:

tools $ GO111MODULE=off go test -short -count=1 ./refactor/importgraph
ok	1.110s
tools $ GO111MODULE=on go test -short -count=1 ./refactor/importgraph
ok	283.044s

/cc @ianthehat @matloob

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