Skip to content

Commit a5d61d7

Browse files
dmitshurgopherbot
authored andcommitted
runtime: deprecate GOROOT
Fixes #51473. Change-Id: Ic868790f480b21b472c98b39be797bcffb1fa892 Reviewed-on: https://go-review.googlesource.com/c/go/+/564142 Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 830621b commit a5d61d7

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

api/next/51473.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkg runtime, func GOROOT //deprecated #51473
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The [GOROOT] function is now deprecated.
2+
In new code prefer to use the system path to locate the “go” binary,
3+
and use `go env GOROOT` to find its GOROOT.

src/runtime/extern.go

+5
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ var defaultGOROOT string // set by cmd/link
336336
// GOROOT returns the root of the Go tree. It uses the
337337
// GOROOT environment variable, if set at process start,
338338
// or else the root used during the Go build.
339+
//
340+
// Deprecated: The root used during the Go build will not be
341+
// meaningful if the binary is copied to another machine.
342+
// Use the system path to locate the “go” binary, and use
343+
// “go env GOROOT” to find its GOROOT.
339344
func GOROOT() string {
340345
s := gogetenv("GOROOT")
341346
if s != "" {

0 commit comments

Comments
 (0)