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