github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/bug.txt (about)

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