...

Text file src/cmd/go/testdata/script/goline_order.txt

Documentation: cmd/go/testdata/script

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

View as plain text