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

     1  [gccgo] skip 'gccgo has no standard packages'
     2  [short] skip
     3  
     4  [!windows] env NONEXE='.exe'
     5  [windows] env NONEXE=''
     6  
     7  env GOBIN=$WORK/tmp/bin
     8  go install m/isarchive &
     9  
    10  go build x.go
    11  exists -exec x$GOEXE
    12  rm x$GOEXE
    13  ! exists x$NONEXE
    14  
    15  go build -o myprog x.go
    16  ! exists x
    17  ! exists x.exe
    18  exists -exec myprog
    19  ! exists myprogr.exe
    20  
    21  ! exists bin
    22  go build -o bin/x x.go
    23  exists -exec bin/x
    24  rm bin
    25  
    26  ! exists bin
    27  go build -o bin/ x.go
    28  exists -exec bin/x$GOEXE
    29  rm bin
    30  
    31  [windows] ! exists bin
    32  [windows] go build -o bin\x x.go
    33  [windows] exists -exec bin\x
    34  [windows] rm bin
    35  
    36  [windows] ! exists bin
    37  [windows] go build -o bin\ x.go
    38  [windows] exists -exec bin\x.exe
    39  [windows] rm bin
    40  
    41  ! exists bin
    42  mkdir bin
    43  go build -o bin x.go
    44  exists -exec bin/x$GOEXE
    45  rm bin
    46  
    47  go build p.go
    48  ! exists p
    49  ! exists p.a
    50  ! exists p.o
    51  ! exists p.exe
    52  
    53  wait # for isarchive
    54  
    55  go build -o p.a p.go
    56  exists p.a
    57  exec $GOBIN/isarchive p.a
    58  
    59  go build cmd/gofmt
    60  exists -exec gofmt$GOEXE
    61  rm gofmt$GOEXE
    62  ! exists gofmt$NONEXE
    63  
    64  go build -o mygofmt cmd/gofmt
    65  exists -exec mygofmt
    66  ! exists mygofmt.exe
    67  ! exists gofmt
    68  ! exists gofmt.exe
    69  
    70  go build sync/atomic
    71  ! exists atomic
    72  ! exists atomic.exe
    73  
    74  go build -o myatomic.a sync/atomic
    75  exists myatomic.a
    76  exec $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
    82  stderr 'multiple packages'
    83  
    84  -- go.mod --
    85  module m
    86  
    87  go 1.16
    88  -- x.go --
    89  package main
    90  
    91  func main() {}
    92  -- p.go --
    93  package p
    94  -- isarchive/isarchive.go --
    95  package main
    96  
    97  import (
    98  	"bytes"
    99  	"fmt"
   100  	"io"
   101  	"os"
   102  )
   103  
   104  func 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  }
   118  

View as plain text