1
0
mirror of https://github.com/golang/go synced 2024-11-26 07:17:59 -07:00

cmd/go: use builtin version and reexec for env

Skip execing for version (most reliable) and attempt to reexec
for env, falling back to the go in GOROOT

Fixes #43981

Change-Id: I17fb84d36036807274eecca3d4f64b3add9b9483
Reviewed-on: https://go-review.googlesource.com/c/go/+/288693
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Sean Liao 2021-02-02 18:08:50 +01:00 committed by Bryan C. Mills
parent d2f96f2f75
commit c3e2ed711c
2 changed files with 19 additions and 3 deletions

View File

@ -81,7 +81,7 @@ func printGoVersion(w io.Writer) {
fmt.Fprintf(w, "### What version of Go are you using (`go version`)?\n\n") fmt.Fprintf(w, "### What version of Go are you using (`go version`)?\n\n")
fmt.Fprintf(w, "<pre>\n") fmt.Fprintf(w, "<pre>\n")
fmt.Fprintf(w, "$ go version\n") fmt.Fprintf(w, "$ go version\n")
printCmdOut(w, "", "go", "version") fmt.Fprintf(w, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
fmt.Fprintf(w, "</pre>\n") fmt.Fprintf(w, "</pre>\n")
fmt.Fprintf(w, "\n") fmt.Fprintf(w, "\n")
} }
@ -90,7 +90,11 @@ func printEnvDetails(w io.Writer) {
fmt.Fprintf(w, "### What operating system and processor architecture are you using (`go env`)?\n\n") fmt.Fprintf(w, "### What operating system and processor architecture are you using (`go env`)?\n\n")
fmt.Fprintf(w, "<details><summary><code>go env</code> Output</summary><br><pre>\n") fmt.Fprintf(w, "<details><summary><code>go env</code> Output</summary><br><pre>\n")
fmt.Fprintf(w, "$ go env\n") fmt.Fprintf(w, "$ go env\n")
printCmdOut(w, "", "go", "env") goexe, err := os.Executable()
if err != nil {
goexe = filepath.Join(runtime.GOROOT(), "bin/go")
}
printCmdOut(w, "", goexe, "env")
printGoDetails(w) printGoDetails(w)
printOSDetails(w) printOSDetails(w)
printCDetails(w) printCDetails(w)

View File

@ -1,9 +1,11 @@
# Verify that go bug creates the appropriate URL issue body # Verify that go bug creates the appropriate URL issue body
[!linux] skip [!linux] skip
[short] skip
go install go install
env BROWSER=$GOPATH/bin/browser go build -o $TMPDIR/go ./go
env BROWSER=$GOPATH/bin/browser PATH=$TMPDIR:$PATH
go bug go bug
exists $TMPDIR/browser exists $TMPDIR/browser
grep '^go version' $TMPDIR/browser grep '^go version' $TMPDIR/browser
@ -44,3 +46,13 @@ func main() {
} }
} }
-- go/main.go --
package main
import (
"os"
)
func main() {
os.Exit(1)
}