...

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

Documentation: cmd/go/testdata/script

     1env GO111MODULE=off
     2
     3# GOFLAGS sets flags for commands
     4
     5env GOFLAGS='-e -f={{.Dir}} --test.benchtime=1s -count=10'
     6go list asdfasdfasdf  # succeeds because of -e
     7go list runtime
     8stdout '[\\/]runtime$'
     9
    10env GOFLAGS=-race OLDGOARCH=$GOARCH OLDGOOS=$GOOS GOARCH=386 GOOS=linux
    11! go list runtime
    12stderr 'race is not supported on linux/386'
    13
    14env GOARCH=$OLDGOARCH GOOS=$OLDGOOS
    15
    16# go env succeeds even though -f={{.Dir}} is inappropriate
    17go env
    18
    19# bad flags are diagnosed
    20env GOFLAGS=-typoflag
    21! go list runtime
    22stderr 'unknown flag -typoflag'
    23
    24env GOFLAGS=-
    25! go list runtime
    26stderr '^go: parsing \$GOFLAGS: non-flag "-"'
    27
    28env GOFLAGS=--
    29! go list runtime
    30stderr '^go: parsing \$GOFLAGS: non-flag "--"'
    31
    32env GOFLAGS=---oops
    33! go list runtime
    34stderr '^go: parsing \$GOFLAGS: non-flag "---oops"'
    35
    36env GOFLAGS=-=noname
    37! go list runtime
    38stderr '^go: parsing \$GOFLAGS: non-flag "-=noname"'
    39
    40env GOFLAGS=-f
    41! go list runtime
    42stderr '^go: flag needs an argument: -f \(from (\$GOFLAGS|%GOFLAGS%)\)$'
    43
    44env GOFLAGS=-e=asdf
    45! go list runtime
    46stderr '^go: invalid boolean value \"asdf\" for flag -e \(from (\$GOFLAGS|%GOFLAGS%)\)'
    47
    48# except in go bug (untested) and go env
    49go env
    50stdout GOFLAGS
    51
    52# Flags listed in GOFLAGS should be safe to duplicate on the command line.
    53env GOFLAGS=-tags=magic
    54go list -tags=magic
    55go test -tags=magic -c -o $devnull
    56go vet -tags=magic
    57
    58# GOFLAGS uses the same quoting rules (quoted.Split) as the rest of
    59# the go command env variables
    60env GOFLAGS='"-tags=magic wizardry"'
    61go list
    62
    63-- foo_test.go --
    64package foo

View as plain text