]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: deprecate GOROOT
authorDmitri Shuralyov <dmitshur@golang.org>
Thu, 15 Feb 2024 00:08:02 +0000 (19:08 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 20 Aug 2024 22:49:59 +0000 (22:49 +0000)
Fixes #51473.

Change-Id: Ic868790f480b21b472c98b39be797bcffb1fa892
Reviewed-on: https://go-review.googlesource.com/c/go/+/564142
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

api/next/51473.txt [new file with mode: 0644]
doc/next/6-stdlib/99-minor/runtime/51473.md [new file with mode: 0644]
src/runtime/extern.go

diff --git a/api/next/51473.txt b/api/next/51473.txt
new file mode 100644 (file)
index 0000000..c47a629
--- /dev/null
@@ -0,0 +1 @@
+pkg runtime, func GOROOT //deprecated #51473
diff --git a/doc/next/6-stdlib/99-minor/runtime/51473.md b/doc/next/6-stdlib/99-minor/runtime/51473.md
new file mode 100644 (file)
index 0000000..9083766
--- /dev/null
@@ -0,0 +1,3 @@
+The [GOROOT] function is now deprecated.
+In new code prefer to use the system path to locate the “go” binary,
+and use `go env GOROOT` to find its GOROOT.
index 2019be4ddec4f3758507b069c5dd8a4a8eae164e..f8f81be8ef4357b94bb4b01461ba36f603eefaa4 100644 (file)
@@ -336,6 +336,11 @@ var defaultGOROOT string // set by cmd/link
 // GOROOT returns the root of the Go tree. It uses the
 // GOROOT environment variable, if set at process start,
 // or else the root used during the Go build.
+//
+// Deprecated: The root used during the Go build will not be
+// meaningful if the binary is copied to another machine.
+// Use the system path to locate the “go” binary, and use
+// “go env GOROOT” to find its GOROOT.
 func GOROOT() string {
        s := gogetenv("GOROOT")
        if s != "" {