Text file
src/cmd/go/testdata/script/mod_get_go_directive_implicit.txt
1 # go.dev/issue/63507: in a module whose go.mod has no go directive, 'go get'
2 # synthesizes the version of the go command itself internally. The change must
3 # be reported against the version the module implicitly had, go 1.16, not
4 # against whichever go command happened to run.
5
6 env TESTGO_VERSION=go1.99
7
8 # No go directive: 'go get go@1.20' writes one. The module was implicitly at
9 # go 1.16, so this is an upgrade from 1.16, not a downgrade from go1.99.
10 # Moving past 1.17 expands the requirements, so the existing note applies.
11 go get go@1.20
12 stderr '^go: upgraded implicit go 1.16 => 1.20$'
13 stderr 'note: expanded dependencies to upgrade to go 1.17 or higher'
14 ! stderr 'downgraded'
15 grep '^go 1.20$' go.mod
16
17 # The same holds when the new version is the version of the go command: the
18 # module still moves from the implicit go 1.16, so the change is reported.
19 cp go.mod.none go.mod
20 go get go@1.99
21 stderr '^go: upgraded implicit go 1.16 => 1.99$'
22 grep '^go 1.99$' go.mod
23 ! grep '^toolchain' go.mod
24
25 # Below the implicit version is a real downgrade.
26 cp go.mod.none go.mod
27 go get go@1.15
28 stderr '^go: downgraded implicit go 1.16 => 1.15$'
29 grep '^go 1.15$' go.mod
30
31 # Writing the implicit version explicitly changes nothing, so it stays silent.
32 cp go.mod.none go.mod
33 go get go@1.16
34 ! stderr 'implicit'
35 ! stderr 'go: (added|upgraded|downgraded) go'
36 grep '^go 1.16$' go.mod
37
38 # A version go.mod really declared is reported without 'implicit', including
39 # when it declares the same 1.16 that the implicit version would have been.
40 cp go.mod.116 go.mod
41 go get go@1.20
42 stderr '^go: upgraded go 1.16 => 1.20$'
43 ! stderr 'implicit'
44
45 cp go.mod.high go.mod
46 go get go@1.20
47 stderr '^go: downgraded go 1.25 => 1.20$'
48
49 cp go.mod.low go.mod
50 go get go@1.20
51 stderr '^go: upgraded go 1.18 => 1.20$'
52
53 # This is not specific to 'go get go@version'. Getting a package writes the
54 # directive as a side effect, and that is now reported too.
55 cp go.mod.none go.mod
56 go get rsc.io/quote@v1.5.2
57 stderr '^go: upgraded implicit go 1.16 => 1.99$'
58
59 -- go.mod --
60 module example.com/m
61
62 -- go.mod.none --
63 module example.com/m
64
65 -- go.mod.116 --
66 module example.com/m
67 go 1.16
68
69 -- go.mod.high --
70 module example.com/m
71 go 1.25
72
73 -- go.mod.low --
74 module example.com/m
75 go 1.18
76
View as plain text