From: Paul Jolly Date: Thu, 2 Aug 2018 11:41:14 +0000 (+0100) Subject: cmd/go: update go bug to be more consistent with Github issue template X-Git-Tag: go1.13beta1~423 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8b2bd6f5ff3edf24b39294c7d1a86afbd1cfc4f1;p=gostls13.git cmd/go: update go bug to be more consistent with Github issue template As a result of using go env, the following new environment variables are shown as part of the env section: +CGO_CFLAGS="-g -O2" +CGO_CPPFLAGS="" +CGO_CXXFLAGS="-g -O2" +CGO_FFLAGS="-g -O2" +CGO_LDFLAGS="-g -O2" +PKG_CONFIG="pkg-config" +GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build612849170=/tmp/go-build -gno-record-gcc-switches" The diff between the web-based template and the result of go bug is now: +GOROOT/bin/go version: go version devel +478f3a5384 Wed Mar 27 16:21:00 2019 +0000 linux/amd64 +GOROOT/bin/go tool compile -V: compile version devel +478f3a5384 Wed Mar 27 16:21:00 2019 +0000 +uname -sr: Linux 4.15.0-46-generic +Distributor ID: Ubuntu +Description: Ubuntu 18.04.2 LTS +Release: 18.04 +Codename: bionic +/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27. Fixes #26751 Change-Id: I32baca1c3c06d08068dad0041a43a1f5532bd91e Reviewed-on: https://go-review.googlesource.com/c/go/+/127495 Reviewed-by: Daniel Martí Reviewed-by: Brad Fitzpatrick Run-TryBot: Daniel Martí --- diff --git a/src/cmd/go/internal/bug/bug.go b/src/cmd/go/internal/bug/bug.go index 77a1677125..fe71281ef0 100644 --- a/src/cmd/go/internal/bug/bug.go +++ b/src/cmd/go/internal/bug/bug.go @@ -20,7 +20,6 @@ import ( "cmd/go/internal/base" "cmd/go/internal/cfg" - "cmd/go/internal/envcmd" "cmd/go/internal/web" ) @@ -44,23 +43,10 @@ func runBug(cmd *base.Command, args []string) { } var buf bytes.Buffer buf.WriteString(bugHeader) - inspectGoVersion(&buf) - fmt.Fprint(&buf, "#### System details\n\n") - fmt.Fprintln(&buf, "```") - fmt.Fprintf(&buf, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) - env := cfg.CmdEnv - env = append(env, envcmd.ExtraEnvVars()...) - for _, e := range env { - // Hide the TERM environment variable from "go bug". - // See issue #18128 - if e.Name != "TERM" { - fmt.Fprintf(&buf, "%s=\"%s\"\n", e.Name, e.Value) - } - } - printGoDetails(&buf) - printOSDetails(&buf) - printCDetails(&buf) - fmt.Fprintln(&buf, "```") + printGoVersion(&buf) + buf.WriteString("### Does this issue reproduce with the latest release?\n\n\n") + printEnvDetails(&buf) + buf.WriteString(bugFooter) body := buf.String() url := "https://github.com/golang/go/issues/new?body=" + urlpkg.QueryEscape(body) @@ -70,22 +56,47 @@ func runBug(cmd *base.Command, args []string) { } } -const bugHeader = `Please answer these questions before submitting your issue. Thanks! +const bugHeader = ` + +` +const bugFooter = `### What did you do? -#### What did you do? + + -#### What did you expect to see? +### What did you expect to see? -#### What did you see instead? +### What did you see instead? ` +func printGoVersion(w io.Writer) { + fmt.Fprintf(w, "### What version of Go are you using (`go version`)?\n\n") + fmt.Fprintf(w, "
\n")
+	fmt.Fprintf(w, "$ go version\n")
+	printCmdOut(w, "", "go", "version")
+	fmt.Fprintf(w, "
\n") + fmt.Fprintf(w, "\n") +} + +func printEnvDetails(w io.Writer) { + fmt.Fprintf(w, "### What operating system and processor architecture are you using (`go env`)?\n\n") + fmt.Fprintf(w, "
go env Output
\n")
+	fmt.Fprintf(w, "$ go env\n")
+	printCmdOut(w, "", "go", "env")
+	printGoDetails(w)
+	printOSDetails(w)
+	printCDetails(w)
+	fmt.Fprintf(w, "
\n\n") +} + func printGoDetails(w io.Writer) { printCmdOut(w, "GOROOT/bin/go version: ", filepath.Join(runtime.GOROOT(), "bin/go"), "version") printCmdOut(w, "GOROOT/bin/go tool compile -V: ", filepath.Join(runtime.GOROOT(), "bin/go"), "tool", "compile", "-V") @@ -132,35 +143,6 @@ func printCDetails(w io.Writer) { } } -func inspectGoVersion(w io.Writer) { - data, err := web.GetBytes(&urlpkg.URL{ - Scheme: "https", - Host: "golang.org", - Path: "/VERSION", - RawQuery: "?m=text", - }) - if err != nil { - if cfg.BuildV { - fmt.Printf("failed to read from golang.org/VERSION: %v\n", err) - } - return - } - - // golang.org/VERSION currently returns a whitespace-free string, - // but just in case, protect against that changing. - // Similarly so for runtime.Version. - release := string(bytes.TrimSpace(data)) - vers := strings.TrimSpace(runtime.Version()) - - if vers == release { - // Up to date - return - } - - // Devel version or outdated release. Either way, this request is apropos. - fmt.Fprintf(w, "#### Does this issue reproduce with the latest release (%s)?\n\n\n", release) -} - // printCmdOut prints the output of running the given command. // It ignores failures; 'go bug' is best effort. func printCmdOut(w io.Writer, prefix, path string, args ...string) { diff --git a/src/cmd/go/testdata/script/bug.txt b/src/cmd/go/testdata/script/bug.txt new file mode 100644 index 0000000000..f8bc9e7c1d --- /dev/null +++ b/src/cmd/go/testdata/script/bug.txt @@ -0,0 +1,47 @@ +# Verify that go bug creates the appropriate URL issue body + +[!linux] skip + +go install +env BROWSER=$GOPATH/bin/browser +go bug +exists $TMPDIR/browser +grep '^go version' $TMPDIR/browser +grep '^GOROOT/bin/go version: go version' $TMPDIR/browser +grep '^GOROOT/bin/go tool compile -V: compile version' $TMPDIR/browser +grep '^uname -sr: Linux' $TMPDIR/browser +grep 'GNU C Library' $TMPDIR/browser + +-- go.mod -- +module browser + +-- main.go -- +package main + +import ( + "fmt" + "net/url" + "os" + "path/filepath" +) + +func main() { + u, err := url.Parse(os.Args[1]) + if err != nil { + panic(err) + } + body, err := url.PathUnescape(u.Query().Get("body")) + if err != nil { + panic(err) + } + out := filepath.Join(os.TempDir(), "browser") + f, err := os.Create(out) + if err != nil { + panic(err) + } + fmt.Fprintln(f, body) + if err := f.Close(); err != nil { + panic(err) + } +} +