Commit 8b2bd6f5 authored by Paul Jolly's avatar Paul Jolly Committed by Brad Fitzpatrick

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/+/127495Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
parent 0a4d3529
...@@ -20,7 +20,6 @@ import ( ...@@ -20,7 +20,6 @@ import (
"cmd/go/internal/base" "cmd/go/internal/base"
"cmd/go/internal/cfg" "cmd/go/internal/cfg"
"cmd/go/internal/envcmd"
"cmd/go/internal/web" "cmd/go/internal/web"
) )
...@@ -44,23 +43,10 @@ func runBug(cmd *base.Command, args []string) { ...@@ -44,23 +43,10 @@ func runBug(cmd *base.Command, args []string) {
} }
var buf bytes.Buffer var buf bytes.Buffer
buf.WriteString(bugHeader) buf.WriteString(bugHeader)
inspectGoVersion(&buf) printGoVersion(&buf)
fmt.Fprint(&buf, "#### System details\n\n") buf.WriteString("### Does this issue reproduce with the latest release?\n\n\n")
fmt.Fprintln(&buf, "```") printEnvDetails(&buf)
fmt.Fprintf(&buf, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) buf.WriteString(bugFooter)
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, "```")
body := buf.String() body := buf.String()
url := "https://github.com/golang/go/issues/new?body=" + urlpkg.QueryEscape(body) url := "https://github.com/golang/go/issues/new?body=" + urlpkg.QueryEscape(body)
...@@ -70,22 +56,47 @@ func runBug(cmd *base.Command, args []string) { ...@@ -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. If possible, provide a recipe for reproducing the error.
A complete runnable program is good. A complete runnable program is good.
A link on play.golang.org is best. 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) { func printGoDetails(w io.Writer) {
printCmdOut(w, "GOROOT/bin/go version: ", filepath.Join(runtime.GOROOT(), "bin/go"), "version") 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") 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) { ...@@ -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. // printCmdOut prints the output of running the given command.
// It ignores failures; 'go bug' is best effort. // It ignores failures; 'go bug' is best effort.
func printCmdOut(w io.Writer, prefix, path string, args ...string) { func printCmdOut(w io.Writer, prefix, path string, args ...string) {
......
# 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)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment