]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: don't print deprecation notice for 'go get exe'
authorJay Conrod <jayconrod@google.com>
Tue, 1 Dec 2020 18:51:17 +0000 (13:51 -0500)
committerJay Conrod <jayconrod@google.com>
Tue, 1 Dec 2020 20:11:50 +0000 (20:11 +0000)
It's difficult for module authors to provide installation instructions
that work in both Go 1.15 and 1.16. We'll wait until 1.17 to print a
deprecation warning for installing executables with 'go get'.

Fixes #42885

Change-Id: I835b447e83e760f48fd664e8a117749e0cb59f83
Reviewed-on: https://go-review.googlesource.com/c/go/+/274552
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/go/internal/modget/get.go
src/cmd/go/testdata/script/mod_get_deprecate_install.txt [deleted file]

index ecb014252434a32d8c267139f79925d45386253a..e5f55879ee7396bd71ed9e811ba0644e6fbe31cb 100644 (file)
@@ -436,32 +436,9 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
                work.BuildInit()
                pkgs := load.PackagesForBuild(ctx, pkgPatterns)
                work.InstallPackages(ctx, pkgPatterns, pkgs)
-
-               haveExe := false
-               for _, pkg := range pkgs {
-                       if pkg.Name == "main" {
-                               haveExe = true
-                               break
-                       }
-               }
-               if haveExe {
-                       fmt.Fprint(os.Stderr, "go get: installing executables with 'go get' in module mode is deprecated.")
-                       var altMsg string
-                       if modload.HasModRoot() {
-                               altMsg = `
-       To adjust dependencies of the current module, use 'go get -d'.
-       To install using requirements of the current module, use 'go install'.
-       To install ignoring the current module, use 'go install' with a version,
-       like 'go install example.com/cmd@latest'.
-`
-                       } else {
-                               altMsg = "\n\tUse 'go install pkg@version' instead.\n"
-                       }
-                       fmt.Fprint(os.Stderr, altMsg)
-                       fmt.Fprint(os.Stderr, "\tSee 'go help get' and 'go help install' for more information.\n")
-               }
-               // TODO(golang.org/issue/40276): link to HTML documentation explaining
-               // what's changing and gives more examples.
+               // TODO(#40276): After Go 1.16, print a deprecation notice when building
+               // and installing main packages. 'go install pkg' or
+               // 'go install pkg@version' should be used instead.
        }
 
        if !modload.HasModRoot() {
diff --git a/src/cmd/go/testdata/script/mod_get_deprecate_install.txt b/src/cmd/go/testdata/script/mod_get_deprecate_install.txt
deleted file mode 100644 (file)
index 7f5bcad..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-[short] skip
-
-env GO111MODULE=on
-
-# 'go get' outside a module with an executable prints a deprecation message.
-go get example.com/cmd/a
-stderr '^go get: installing executables with ''go get'' in module mode is deprecated.$'
-stderr 'Use ''go install pkg@version'' instead.'
-
-
-go mod init m
-
-# 'go get' inside a module with a non-main package does not print a message.
-# This will stop building in the future, but it's the command we want to use.
-go get rsc.io/quote
-! stderr deprecated
-
-# 'go get' inside a module with an executable prints a different
-# deprecation message.
-go get example.com/cmd/a
-stderr '^go get: installing executables with ''go get'' in module mode is deprecated.$'
-stderr 'To adjust dependencies of the current module, use ''go get -d'''