| 1 |
# Check that go lines are always >= go lines of dependencies. |
| 2 |
|
| 3 |
# Using too old a release cannot even complete module load. |
| 4 |
env TESTGO_VERSION=go1.21.1 |
| 5 |
env TESTGO_VERSION_SWITCH=switch |
| 6 |
cp go.mod go.mod.orig |
| 7 |
|
| 8 |
# If the offending module is not imported, it's not detected. |
| 9 |
go list |
| 10 |
cmp go.mod go.mod.orig |
| 11 |
|
| 12 |
# Adding the import produces the error. |
| 13 |
# Maybe this should auto-switch, but it requires more plumbing to get this error through, |
| 14 |
# and it's a misconfigured system that should not arise in practice, so not switching is fine. |
| 15 |
! go list -deps -tags usem1 |
| 16 |
cmp go.mod go.mod.orig |
| 17 |
stderr '^go: module ./m1 requires go >= 1.21.2 \(running go 1.21.1\)$' |
| 18 |
|
| 19 |
# go get [email protected] fixes the error. |
| 20 |
cp go.mod.orig go.mod |
| 21 |
go get [email protected] |
| 22 |
go list -deps -tags usem1 |
| 23 |
|
| 24 |
# go get -tags usem1 fixes the error. |
| 25 |
cp go.mod.orig go.mod |
| 26 |
go get -tags usem1 |
| 27 |
go list -deps -tags usem1 |
| 28 |
|
| 29 |
# go get fixes the error. |
| 30 |
cp go.mod.orig go.mod |
| 31 |
go get |
| 32 |
go list -deps -tags usem1 |
| 33 |
|
| 34 |
# Using a new enough release reports the error after module load and suggests 'go mod tidy' |
| 35 |
env TESTGO_VERSION=go1.21.2 |
| 36 |
cp go.mod.orig go.mod |
| 37 |
! go list -deps -tags usem1 |
| 38 |
stderr 'updates to go.mod needed' |
| 39 |
stderr 'go mod tidy' |
| 40 |
go mod tidy |
| 41 |
go list -deps -tags usem1 |
| 42 |
|
| 43 |
# go get also works |
| 44 |
cp go.mod.orig go.mod |
| 45 |
! go list -deps -tags usem1 |
| 46 |
stderr 'updates to go.mod needed' |
| 47 |
stderr 'go mod tidy' |
| 48 |
go get [email protected] |
| 49 |
go list -deps -tags usem1 |
| 50 |
|
| 51 |
|
| 52 |
-- go.mod -- |
| 53 |
module m |
| 54 |
go 1.21.1 |
| 55 |
|
| 56 |
require m1 v0.0.1 |
| 57 |
|
| 58 |
replace m1 => ./m1 |
| 59 |
|
| 60 |
-- m1/go.mod -- |
| 61 |
go 1.21.2 |
| 62 |
|
| 63 |
-- p.go -- |
| 64 |
//go:build usem1 |
| 65 |
|
| 66 |
package p |
| 67 |
|
| 68 |
import _ "m1" |
| 69 |
|
| 70 |
-- p1.go -- |
| 71 |
package p |
| 72 |
|
| 73 |
-- m1/p.go -- |
| 74 |
package p |