...

Text file src/cmd/go/testdata/script/bug.txt

Documentation: cmd/go/testdata/script

     1# Verify that go bug creates the appropriate URL issue body
     2
     3[!GOOS:linux] skip
     4[short] skip
     5
     6go install
     7go build -o $TMPDIR/go ./go
     8env BROWSER=$GOPATH/bin/browser PATH=$TMPDIR:$PATH
     9go bug
    10exists $TMPDIR/browser
    11grep '^go version' $TMPDIR/browser
    12grep '^GOROOT/bin/go version: go version' $TMPDIR/browser
    13grep '^GOROOT/bin/go tool compile -V: compile version' $TMPDIR/browser
    14grep '^uname -sr: Linux' $TMPDIR/browser
    15
    16-- go.mod --
    17module browser
    18
    19-- main.go --
    20package main
    21
    22import (
    23	"fmt"
    24	"net/url"
    25	"os"
    26	"path/filepath"
    27)
    28
    29func main() {
    30	u, err := url.Parse(os.Args[1])
    31	if err != nil {
    32		panic(err)
    33	}
    34	body, err := url.PathUnescape(u.Query().Get("body"))
    35	if err != nil {
    36		panic(err)
    37	}
    38	out := filepath.Join(os.TempDir(), "browser")
    39	f, err := os.Create(out)
    40	if err != nil {
    41		panic(err)
    42	}
    43	fmt.Fprintln(f, body)
    44	if err := f.Close(); err != nil {
    45		panic(err)
    46	}
    47}
    48
    49-- go/main.go --
    50package main
    51
    52import (
    53    "os"
    54)
    55
    56func main() {
    57    os.Exit(1)
    58}

View as plain text