summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/version.txt
blob: adca7af7a9de3c7e5c8a5db15e4106b3bf446a06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Without arguments, we just print Go's own version.
go version
stdout '^go version'

# Flags without files, or paths to misisng files, should error.
! go version missing.exe
! go version -m
stderr 'with arguments'
! go version -v
stderr 'with arguments'

# Neither of the two flags above should be an issue via GOFLAGS.
env GOFLAGS='-m -v'
go version
stdout '^go version'
env GOFLAGS=

env GO111MODULE=on

# Check that very basic version lookup succeeds.
go build empty.go
go version empty$GOEXE
[cgo] go build -ldflags=-linkmode=external empty.go
[cgo] go version empty$GOEXE

# Skip the remaining builds if we are running in short mode.
[short] skip

# Check that 'go version' and 'go version -m' work on a binary built in module mode.
go get rsc.io/fortune
go build -o fortune.exe rsc.io/fortune
go version fortune.exe
stdout '^fortune.exe: .+'
go version -m fortune.exe
stdout '^\tpath\trsc.io/fortune'
stdout '^\tmod\trsc.io/fortune\tv1.0.0'

# Check the build info of a binary built from $GOROOT/src/cmd
go build -o test2json.exe cmd/test2json
go version -m test2json.exe
stdout '^test2json.exe: .+'
stdout '^\tpath\tcmd/test2json$'
! stdout 'mod'

# Repeat the test with -buildmode=pie.
[!buildmode:pie] stop
go build -buildmode=pie -o external.exe rsc.io/fortune
go version external.exe
stdout '^external.exe: .+'
go version -m external.exe
stdout '^\tpath\trsc.io/fortune'
stdout '^\tmod\trsc.io/fortune\tv1.0.0'

# Also test PIE with internal linking.
# currently only supported on linux/amd64, linux/arm64 and windows/amd64.
[!linux] [!windows] stop
[!amd64] [!arm64] stop
go build -buildmode=pie -ldflags=-linkmode=internal -o internal.exe rsc.io/fortune
go version internal.exe
stdout '^internal.exe: .+'
go version -m internal.exe
stdout '^\tpath\trsc.io/fortune'
stdout '^\tmod\trsc.io/fortune\tv1.0.0'

-- go.mod --
module m

-- empty.go --
package main
func main(){}