aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modcmd/download.go
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2020-09-11 13:30:43 -0400
committerJay Conrod <jayconrod@google.com>2020-09-15 12:46:25 +0000
commit03875bd9bc112d25a4496f7ff22888f23a26baea (patch)
tree6f9fc4493cb0b775dabd1affa30d6e4209b153c3 /src/cmd/go/internal/modcmd/download.go
parente3063636124d0e5b2d0fad7912a9c6810629f486 (diff)
downloadgo-03875bd9bc112d25a4496f7ff22888f23a26baea.tar.gz
go-03875bd9bc112d25a4496f7ff22888f23a26baea.zip
cmd/go: add modload.NeedRoot mode for commands that need module root
This makes error reporting a bit more consistent for 'go mod' subcommands. Most of these commands only work in module mode when a go.mod file is present. Setting modload.ForceUseModules reports an error when GO111MODULE=off. Setting modload.RootMode to modload.NeedRoot reports an error when no go.mod file is present. Change-Id: I1daa8d2971cb8658e0c804765839d903734a412e Reviewed-on: https://go-review.googlesource.com/c/go/+/254369 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modcmd/download.go')
-rw-r--r--src/cmd/go/internal/modcmd/download.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/cmd/go/internal/modcmd/download.go b/src/cmd/go/internal/modcmd/download.go
index 6227fd9f33..050a2e0e12 100644
--- a/src/cmd/go/internal/modcmd/download.go
+++ b/src/cmd/go/internal/modcmd/download.go
@@ -80,9 +80,7 @@ type moduleJSON struct {
func runDownload(ctx context.Context, cmd *base.Command, args []string) {
// Check whether modules are enabled and whether we're in a module.
- if cfg.Getenv("GO111MODULE") == "off" {
- base.Fatalf("go: modules disabled by GO111MODULE=off; see 'go help modules'")
- }
+ modload.ForceUseModules = true
if !modload.HasModRoot() && len(args) == 0 {
base.Fatalf("go mod download: no modules specified (see 'go help mod download')")
}