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: change default of GO111MODULE from 'auto' to 'on' #30228

Closed
bcmills opened this issue Feb 14, 2019 · 74 comments

Comments

Projects
None yet
2 participants
@bcmills
Copy link
Member

commented Feb 14, 2019

As noted in https://blog.golang.org/modules2019, “Our aim is for Go 1.13, scheduled for August 2019, to enable module mode by default (that is, to change the default from auto to on) and deprecate GOPATH mode.”

This issue tracks the first part of that goal: changing the default to on.

@bcmills bcmills added this to the Go1.13 milestone Feb 14, 2019

@bcmills bcmills self-assigned this Feb 14, 2019

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Feb 14, 2019

CC @rsc @jayconrod

We will want to do #29433 in conjunction with this change. Otherwise it's way too easy to accidentally create a $GOROOT/go.mod by running a Go command anywhere in $GOROOT that doesn't contain a package.

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Feb 14, 2019

A slight wrinkle: some of the tests in misc/cgo/test use relative imports.

Some options:

  • We could add a go.mod file somewhere in misc, misc/cgo, or misc/cgo/test and convert them to absolute imports.
    • That would break misc/cgo/test in GOPATH mode, since those packages are in neither GOROOT/src nor GOPATH/src.
      • We could add a special-case in the GOPATH-mode importer to fix them, but I hesitate to touch GOPATH mode more than we have to at this point.
  • We could add support for relative imports in module mode.
  • We could keep those tests in GOPATH mode for the foreseeable future.
    • It seems a bit hypocritical to deprecate GOPATH mode without a plan to stop using it ourselves.
@gopherbot

This comment has been minimized.

Copy link

commented Feb 14, 2019

Change https://golang.org/cl/162697 mentions this issue: all: set GO111MODULE=off explicitly in tests that assume GOPATH mode

@gopherbot

This comment has been minimized.

Copy link

commented Feb 14, 2019

Change https://golang.org/cl/162698 mentions this issue: cmd/go: change the default value of GO111MODULE to 'on'

@gopherbot

This comment has been minimized.

Copy link

commented Feb 14, 2019

Change https://golang.org/cl/162699 mentions this issue: cmd/go: only generate a go.mod file during 'go mod init'

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Feb 14, 2019

Blocked on #26924. Let's shave this yak! 🐃

@bcmills

This comment has been minimized.

Copy link
Member Author

commented Feb 14, 2019

I talked with @rsc, and our plan for misc/cgo/test is to remove the relative imports, add a go.mod file, and let them break in GOPATH mode.

@gopherbot

This comment has been minimized.

Copy link

commented Feb 14, 2019

Change https://golang.org/cl/162837 mentions this issue: runtime: make tests that invoke 'go build' module-agnostic

gopherbot pushed a commit that referenced this issue Feb 15, 2019

cmd/go: only generate a go.mod file during 'go mod init'
In the general case, we do not know the correct module path for a new
module unless we have checked its VCS tags for a major version. If we
do not know the correct path, then we should not synthesize a go.mod
file automatically from it.

On the other hand, we don't want to run VCS commands in the working
directory without an explicit request by the user to do so: 'go mod
init' can reasonably invoke a VCS command, but 'go build' should not.

Therefore, we should only create a go.mod file during 'go mod init'.

This change removes the previous behavior of synthesizing a file
automatically, and instead suggests a command that the user can opt to
run explicitly.

Updates #29433
Updates #27009
Updates #30228

Change-Id: I8c4554969db17156e97428df220b129a4d361040
Reviewed-on: https://go-review.googlesource.com/c/162699
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>

nebulabox added a commit to nebulabox/go that referenced this issue Feb 18, 2019

cmd/go: only generate a go.mod file during 'go mod init'
In the general case, we do not know the correct module path for a new
module unless we have checked its VCS tags for a major version. If we
do not know the correct path, then we should not synthesize a go.mod
file automatically from it.

On the other hand, we don't want to run VCS commands in the working
directory without an explicit request by the user to do so: 'go mod
init' can reasonably invoke a VCS command, but 'go build' should not.

Therefore, we should only create a go.mod file during 'go mod init'.

This change removes the previous behavior of synthesizing a file
automatically, and instead suggests a command that the user can opt to
run explicitly.

Updates golang#29433
Updates golang#27009
Updates golang#30228

Change-Id: I8c4554969db17156e97428df220b129a4d361040
Reviewed-on: https://go-review.googlesource.com/c/162699
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/162833 mentions this issue: cmd/link: fix TestUnresolved in module mode

@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/162832 mentions this issue: cmd/internal/goobj: make the buildGoobj test helper work in module mode

@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/162831 mentions this issue: cmd/internal/obj/x86: fix issue19518_test in module mode

@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/162830 mentions this issue: cmd/cover: fix TestHtmlUnformatted in module mode

gopherbot pushed a commit that referenced this issue Feb 19, 2019

cmd/go: set GO111MODULE=off explicitly in tests that assume GOPATH mode
We will soon switch GO111MODULE to 'on' by default, and when that
happens these tests will otherwise break.

Updates #30228

Change-Id: I1016d429b1dfb889d1aae8bc86fb2567cf0fc56f
Reviewed-on: https://go-review.googlesource.com/c/162697
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>

gopherbot pushed a commit that referenced this issue Feb 19, 2019

runtime: make tests that invoke 'go build' module-agnostic
In module mode, building the current directory requires a go.mod file
(in order to determine the import path of the package).

Change the tests to pass explicit file arguments instead, since those
can be built in module mode without defining a module.

Updates #30228

Change-Id: I680c658d1f79645f73ad4d1e88189ea50a4852e9
Reviewed-on: https://go-review.googlesource.com/c/162837
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/163038 mentions this issue: cmd/vet: make vet_test module-agnostic

@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/162835 mentions this issue: cmd/link/internal/ld: make dwarf_test and associated testdata module-agnostic

@gopherbot

This comment has been minimized.

Copy link

commented Feb 19, 2019

Change https://golang.org/cl/162836 mentions this issue: cmd/nm: fix testGoLib helper to be module-agnostic

gopherbot pushed a commit that referenced this issue Feb 19, 2019

cmd/internal/obj/x86: fix issue19518_test in module mode
Updates #30228

Change-Id: I6a38269f322d906702921b3879ff48c8a96ab511
Reviewed-on: https://go-review.googlesource.com/c/162831
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>

gopherbot pushed a commit that referenced this issue Feb 19, 2019

cmd/nm: fix testGoLib helper to be module-agnostic
Updates #30228

Change-Id: I3c7864e6725312df5ec978cdc130ccfe8fc2e738
Reviewed-on: https://go-review.googlesource.com/c/162836
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>

gopherbot pushed a commit that referenced this issue Feb 19, 2019

cmd/internal/goobj: make the buildGoobj test helper work in module mode
Updates #30228

Change-Id: I8dd4a1f94dfd3be324a4f213941a20fa1b8b1215
Reviewed-on: https://go-review.googlesource.com/c/162832
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>

gopherbot pushed a commit that referenced this issue Feb 19, 2019

cmd/link: fix TestUnresolved in module mode
Updates #30228

Change-Id: I9f0e7e59922bd56b17889f72124b7d14b2433218
Reviewed-on: https://go-review.googlesource.com/c/162833
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>

nebulabox added a commit to nebulabox/go that referenced this issue Feb 20, 2019

runtime: make tests that invoke 'go build' module-agnostic
In module mode, building the current directory requires a go.mod file
(in order to determine the import path of the package).

Change the tests to pass explicit file arguments instead, since those
can be built in module mode without defining a module.

Updates golang#30228

Change-Id: I680c658d1f79645f73ad4d1e88189ea50a4852e9
Reviewed-on: https://go-review.googlesource.com/c/162837
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>

nebulabox added a commit to nebulabox/go that referenced this issue Feb 20, 2019

cmd/go: set GO111MODULE=off explicitly in tests that assume GOPATH mode
We will soon switch GO111MODULE to 'on' by default, and when that
happens these tests will otherwise break.

Updates golang#30228

Change-Id: I1016d429b1dfb889d1aae8bc86fb2567cf0fc56f
Reviewed-on: https://go-review.googlesource.com/c/162697
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>

gopherbot pushed a commit to golang/arch that referenced this issue Mar 12, 2019

all: add go.mod
Updates golang/go#30228

Change-Id: Idde6e34da043b401ee7429a0297517ec235e3b64
Reviewed-on: https://go-review.googlesource.com/c/arch/+/167137
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

gopherbot pushed a commit to golang/benchmarks that referenced this issue Mar 12, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: I43900a3d2b59ddb7701436a652ac00e35a49c69d
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/167177
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167178 mentions this issue: all: add go.mod

gopherbot pushed a commit to golang/debug that referenced this issue Mar 12, 2019

all: add go.mod
Created using:
	go mod init && go mod edit -go=1.11 && go mod tidy && go list -m all && go test ./...

Updates golang/go#30228

Change-Id: I0707e709ccd354a1ef39cc622cf13ca17c8ba714
Reviewed-on: https://go-review.googlesource.com/c/debug/+/167178
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167218 mentions this issue: all: add go.mod

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167217 mentions this issue: apidiff: fix tests in module mode

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167180 mentions this issue: all: add go.mod

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167179 mentions this issue: all: set GO111MODULE=off explicitly in bind tests

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167138 mentions this issue: all: add go.mod

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167159 mentions this issue: all: add go.mod

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167160 mentions this issue: all: add go.mod

@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167181 mentions this issue: all: add go.mod

gopherbot pushed a commit to golang/perf that referenced this issue Mar 12, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: I759660fe7d96f1f3d4a4a465c302f524d06401cc
Reviewed-on: https://go-review.googlesource.com/c/perf/+/167138
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

gopherbot pushed a commit to golang/blog that referenced this issue Mar 12, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: I78d903d7151790b37f32a06f37427a50fcd2a83b
Reviewed-on: https://go-review.googlesource.com/c/blog/+/167157
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

gopherbot pushed a commit to golang/term that referenced this issue Mar 12, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: I86819ac0a2704468903e34ca49308ce65149791b
Reviewed-on: https://go-review.googlesource.com/c/term/+/167160
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

gopherbot pushed a commit to golang/exp that referenced this issue Mar 12, 2019

apidiff: fix tests in module mode
Updates golang/go#30228

Change-Id: If138faaa001f557f82eb9d25812a0a89155f639d
Reviewed-on: https://go-review.googlesource.com/c/exp/+/167217
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>

gopherbot pushed a commit to golang/exp that referenced this issue Mar 12, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: Ied34225715beddec6610b793258a01da4a2c32b9
Reviewed-on: https://go-review.googlesource.com/c/exp/+/167218
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

gopherbot pushed a commit to golang/tour that referenced this issue Mar 12, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: I3d7e4f59a98822691177973ec2d7a55a6216b78c
Reviewed-on: https://go-review.googlesource.com/c/tour/+/167181
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Mar 12, 2019

Change https://golang.org/cl/167087 mentions this issue: cmd/go: change the default value of GO111MODULE to 'on'

gopherbot pushed a commit to golang/mobile that referenced this issue Mar 13, 2019

all: set GO111MODULE=off explicitly in bind tests
Updates golang/go#27234
Updates golang/go#30228

Change-Id: Ibe281480398ff9d8c27657f399159885a75f646e
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167179
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

gopherbot pushed a commit to golang/mobile that referenced this issue Mar 13, 2019

all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228
Updates golang/go#27234

Change-Id: Ibf3b104bfaa037e1a94a5327b5a56983d9744e73
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/167180
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

gopherbot pushed a commit to golang/talks that referenced this issue Mar 13, 2019

all: add go.mod
Commands run:
	sed -i 's;// +build OMIT;// +build ignore,OMIT;' $(grep -l OMIT -r)
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228
Updates golang/go#29598

Change-Id: I3d0a4787c1158572bed8dd3785ff02e16d1cc1f3
Reviewed-on: https://go-review.googlesource.com/c/talks/+/167159
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>

@gopherbot gopherbot closed this in eca5c83 Mar 14, 2019

@gopherbot

This comment has been minimized.

Copy link

commented Mar 14, 2019

Change https://golang.org/cl/167703 mentions this issue: all: add go.mod

gopherbot pushed a commit to golang/dl that referenced this issue Mar 14, 2019

all: add go.mod
Copy golang.org/x/build/envutil.Dedup locally to avoid pulling in all
of x/build.

Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: I0fc24565c08a73db067daf080b46f4aa82a63c41
Reviewed-on: https://go-review.googlesource.com/c/dl/+/167703
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented Mar 15, 2019

Change https://golang.org/cl/167740 mentions this issue: cmd/cover: add go.mod file in lineDupDir

gopherbot pushed a commit that referenced this issue Mar 15, 2019

cmd/cover: add go.mod file in lineDupDir
This fixes TestFuncWithDuplicateLines (introduced in CL 167257)
in module mode.

Updates #30746
Updates #30228

Change-Id: I7b3e7192ae23f855c373e881389874ff6ffd49ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/167740
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
@gopherbot

This comment has been minimized.

Copy link

commented May 6, 2019

Change https://golang.org/cl/175441 mentions this issue: [release-branch.go1.12] cmd/go/internal/imports: use the full path to resolve symlinks

gopherbot pushed a commit that referenced this issue May 6, 2019

[release-branch.go1.12] cmd/go/internal/imports: use the full path to…
… resolve symlinks

info.Name returns a name relative to the directory, so we need to
prefix that directory in the Stat call.

(This was missed in CL 141097 due to the fact that the test only
happened to check symlinks in the current directory.)

This allows the misc/ tests to work in module mode on platforms that
support symlinks.

Updates #30228
Updates #28107
Fixes #31763

Change-Id: Ie31836382df0cbd7d203b7a8b637c4743d68b6f3
Reviewed-on: https://go-review.googlesource.com/c/163517
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/175441
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
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.