]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: update go bug to be more consistent with Github issue template
authorPaul Jolly <paul@myitcv.io>
Thu, 2 Aug 2018 11:41:14 +0000 (12:41 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 3 May 2019 17:03:18 +0000 (17:03 +0000)
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í <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>

src/cmd/go/internal/bug/bug.go
src/cmd/go/testdata/script/bug.txt [new file with mode: 0644]

index 77a1677125dfe03bd83c9b8de5e0f52798d3b9ad..fe71281ef054ebebf4a3f51c0f267acbdc4aa999 100644 (file)
@@ -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 = `<!-- Please answer these questions before submitting your issue. Thanks! -->
+
+`
+const bugFooter = `### What did you do?
 
-#### What did you do?
+<!--
 If possible, provide a recipe for reproducing the error.
 A complete runnable program is good.
 A link on play.golang.org is best.
+-->
+
 
 
-#### 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, "<pre>\n")
+       fmt.Fprintf(w, "$ go version\n")
+       printCmdOut(w, "", "go", "version")
+       fmt.Fprintf(w, "</pre>\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, "<details><summary><code>go env</code> Output</summary><br><pre>\n")
+       fmt.Fprintf(w, "$ go env\n")
+       printCmdOut(w, "", "go", "env")
+       printGoDetails(w)
+       printOSDetails(w)
+       printCDetails(w)
+       fmt.Fprintf(w, "</pre></details>\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 (file)
index 0000000..f8bc9e7
--- /dev/null
@@ -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)
+       }
+}
+