]> Cypherpunks repositories - gostls13.git/commit
cmd/go: mod init outside of GOPATH silently fails
authorRens Rikkerink <1952177+ikkerens@users.noreply.github.com>
Tue, 9 Apr 2019 20:16:35 +0000 (20:16 +0000)
committerBryan C. Mills <bcmills@google.com>
Thu, 18 Apr 2019 17:23:47 +0000 (17:23 +0000)
commit3e2ceaf4def85005d90d37b8b4510d3e40b16fb7
tree6fea5a7fe48f7515b29356148735ed78d8c3c41a
parent3235f7c0720338a160debe6e9c632b8af968b4dd
cmd/go: mod init outside of GOPATH silently fails

Running `go mod init` outside of GOPATH with `GO111MODULE=off`
silently fails. This behavior was undocumented.

This CL makes go mod fail with the error:

   go: modules disabled by GO111MODULE=off; see 'go help modules'
Comparing with already erroring GO111MODULE=<value> conditions:

* With GO111MODULE=auto, inside GOPATH:
    go modules disabled inside GOPATH/src by GO111MODULE=auto; see 'go help modules'
* With GO111MODULE=auto outside of GOPATH:
    go: cannot determine module path for source directory /path/to/dir (outside GOPATH, no import comments)

Fixes #31342

Change-Id: I749787d2a8640913c4ac263072d051314d76e778
GitHub-Last-Rev: b38447457d8cabed367ea4872cf7f238a49539c7
GitHub-Pull-Request: golang/go#31255
Reviewed-on: https://go-review.googlesource.com/c/go/+/170697
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/go/internal/modcmd/init.go
src/cmd/go/testdata/script/mod_off_init.txt [new file with mode: 0644]