1 # Without arguments, we just print Go's own version.
2 go version
3 stdout '^go version'
4
5 # Flags without files, or paths to misisng files, should error.
6 ! go version missing.exe
7 ! go version -m
8 stderr 'with arguments'
9 ! go version -v
10 stderr 'with arguments'
11
12 # Neither of the two flags above should be an issue via GOFLAGS.
13 env GOFLAGS='-m -v'
14 go version
15 stdout '^go version'
16 env GOFLAGS=
17
18 env GO111MODULE=on
19 # Skip the builds below if we are running in short mode.
20 [short] skip
21
22 # Check that 'go version' and 'go version -m' work on a binary built in module mode.
23 go get -d rsc.io/fortune
24 go build -o fortune.exe rsc.io/fortune
25 go version fortune.exe
26 stdout '^fortune.exe: .+'
27 go version -m fortune.exe
28 stdout '^\tpath\trsc.io/fortune'
29 stdout '^\tmod\trsc.io/fortune\tv1.0.0'
30
31 # Repeat the test with -buildmode=pie.
32 [!buildmode:pie] stop
33 go build -buildmode=pie -o external.exe rsc.io/fortune
34 go version external.exe
35 stdout '^external.exe: .+'
36 go version -m external.exe
37 stdout '^\tpath\trsc.io/fortune'
38 stdout '^\tmod\trsc.io/fortune\tv1.0.0'
39
40 # Also test PIE with internal linking.
41 # currently only supported on linux/amd64, linux/arm64 and windows/amd64.
42 [!linux] [!windows] stop
43 [!amd64] [!arm64] stop
44 go build -buildmode=pie -ldflags=-linkmode=internal -o internal.exe rsc.io/fortune
45 go version internal.exe
46 stdout '^internal.exe: .+'
47 go version -m internal.exe
48 stdout '^\tpath\trsc.io/fortune'
49 stdout '^\tmod\trsc.io/fortune\tv1.0.0'
50
51 -- go.mod --
52 module m
53
View as plain text