...

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

Documentation: cmd/go/testdata/script

     1[compiler:gccgo] skip 'gccgo has no standard packages'
     2[short] skip
     3
     4[!GOOS:windows] env NONEXE='.exe'
     5[GOOS:windows] env NONEXE=''
     6
     7env GOBIN=$WORK/tmp/bin
     8go install m/isarchive &
     9
    10go build x.go
    11exists -exec x$GOEXE
    12rm x$GOEXE
    13! exists x$NONEXE
    14
    15go build -o myprog x.go
    16! exists x
    17! exists x.exe
    18exists -exec myprog
    19! exists myprogr.exe
    20
    21! exists bin
    22go build -o bin/x x.go
    23exists -exec bin/x
    24rm bin
    25
    26! exists bin
    27go build -o bin/ x.go
    28exists -exec bin/x$GOEXE
    29rm bin
    30
    31[GOOS:windows] ! exists bin
    32[GOOS:windows] go build -o bin\x x.go
    33[GOOS:windows] exists -exec bin\x
    34[GOOS:windows] rm bin
    35
    36[GOOS:windows] ! exists bin
    37[GOOS:windows] go build -o bin\ x.go
    38[GOOS:windows] exists -exec bin\x.exe
    39[GOOS:windows] rm bin
    40
    41! exists bin
    42mkdir bin
    43go build -o bin x.go
    44exists -exec bin/x$GOEXE
    45rm bin
    46
    47go build p.go
    48! exists p
    49! exists p.a
    50! exists p.o
    51! exists p.exe
    52
    53wait # for isarchive
    54
    55go build -o p.a p.go
    56exists p.a
    57exec $GOBIN/isarchive p.a
    58
    59go build cmd/gofmt
    60exists -exec gofmt$GOEXE
    61rm gofmt$GOEXE
    62! exists gofmt$NONEXE
    63
    64go build -o mygofmt cmd/gofmt
    65exists -exec mygofmt
    66! exists mygofmt.exe
    67! exists gofmt
    68! exists gofmt.exe
    69
    70go build sync/atomic
    71! exists atomic
    72! exists atomic.exe
    73
    74go build -o myatomic.a sync/atomic
    75exists myatomic.a
    76exec $GOBIN/isarchive myatomic.a
    77! exists atomic
    78! exists atomic.a
    79! exists atomic.exe
    80
    81! go build -o whatever cmd/gofmt sync/atomic
    82stderr 'multiple packages'
    83
    84-- go.mod --
    85module m
    86
    87go 1.16
    88-- x.go --
    89package main
    90
    91func main() {}
    92-- p.go --
    93package p
    94-- isarchive/isarchive.go --
    95package main
    96
    97import (
    98	"bytes"
    99	"fmt"
   100	"io"
   101	"os"
   102)
   103
   104func main() {
   105	f, err := os.Open(os.Args[1])
   106	if err != nil {
   107		fmt.Fprintln(os.Stderr, err)
   108		os.Exit(1)
   109	}
   110	buf := make([]byte, 100)
   111	io.ReadFull(f, buf)
   112	f.Close()
   113	if !bytes.HasPrefix(buf, []byte("!<arch>\n")) {
   114		fmt.Fprintf(os.Stderr, "file %s exists but is not an archive\n", os.Args[1])
   115		os.Exit(1)
   116	}
   117}

View as plain text