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 · 76 comments
Closed

cmd/go: change default of GO111MODULE from 'auto' to 'on' #30228

bcmills opened this issue Feb 14, 2019 · 76 comments
Labels
early-in-cycle A change that should be done early in the 3 month dev cycle. FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills 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 NeedsFix The path to resolution is known, but the work has not been done. early-in-cycle A change that should be done early in the 3 month dev cycle. modules labels Feb 14, 2019
@bcmills bcmills added this to the Go1.13 milestone Feb 14, 2019
@bcmills bcmills self-assigned this Feb 14, 2019
@bcmills
Copy link
Contributor Author

bcmills 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
Copy link
Contributor Author

bcmills 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
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@bcmills
Copy link
Contributor Author

bcmills commented Feb 14, 2019

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

@bcmills
Copy link
Contributor Author

bcmills 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
Copy link

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
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 pushed a commit to nebulabox/go that referenced this issue Feb 18, 2019
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
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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
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
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
Copy link

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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
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
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
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
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 pushed a commit to nebulabox/go that referenced this issue Feb 20, 2019
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 pushed a commit to nebulabox/go that referenced this issue Feb 20, 2019
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
Copy link

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

@gopherbot
Copy link

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
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
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
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
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
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
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
Copy link

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
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
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
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
Copy link

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
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
Copy link

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
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
Copy link

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
… 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>
@gopherbot
Copy link

Change https://golang.org/cl/222538 mentions this issue: vendor: migrate from govendor to go mod vendor

gopherbot pushed a commit to golang/arch that referenced this issue Mar 12, 2020
The rsc.io/pdf package was added to the vendor directory 5 years ago
in CL 13968, back when the vendor directory was a part of the Go 1.5
vendor experiment.

The vendor.json file was written by hand in a format compatible with
the govendor tool. By now, that tool has been deprecated in favor of
the go command in module mode.

A go.mod file requiring a newer version of rsc.io/pdf was added in
CL 167137. Modify the vendor directory to use the newer rsc.io/pdf
version by recreating vendor directory using go command in Go 1.14:

	rm -rf vendor
	go mod vendor

It's possible the vendor directory isn't needed anymore and can be
safely deleted in a future change. The scope of this CL is only to
migrate from the deprecated govendor tool to the supported go tool;
deleting the vendor directory can still be done in a future change.

Remove the explicit mention of Go 1.5 vendor experiment from README
since it's old, and not relevant by now. Add a contributing section.

Updates golang/go#30228
Updates golang/go#33848

Change-Id: I95de95a3b2d81faf7235c675e5b8d425141f8d7a
Reviewed-on: https://go-review.googlesource.com/c/arch/+/222538
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/225205 mentions this issue: test: make runindir tests pass regardless of whether module mode is in use

gopherbot pushed a commit that referenced this issue Mar 25, 2020
…n use

The "runindir" tests used "go run", but relied on relative imports
(which are not supported by "go run" in module mode). Instead, such
tests must use fully-qualified imports, which require either a go.mod
file (in module mode) or that the package be in an appropriate
subdirectory of GOPATH/src (in GOPATH mode).

To set up such a directory, we use yet another copy of the same
overlayDir function currently found in the misc subdirectory of this
repository.

Fixes #33912
Updates #30228

Change-Id: If3d7ea2f7942ba496d98aaaf24a90bcdcf4df9f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/225205
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Mar 24, 2021
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
early-in-cycle A change that should be done early in the 3 month dev cycle. FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants