...

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

Documentation: cmd/go/testdata/script

     1env TESTGO_VERSION=go1.21.0
     2env TESTGO_VERSION_SWITCH=switch
     3
     4# If the main module's go.mod file lists a version lower than the version
     5# required by its dependencies, the commands that fetch and diagnose the module
     6# graph (such as 'go mod graph' and 'go mod verify') should fail explicitly:
     7# they can't interpret the graph themselves, and they aren't allowed to update
     8# the go.mod file to record a specific, stable toolchain version that can.
     9
    10! go mod verify
    11stderr '^go: rsc.io/future@v1.0.0: module rsc.io/future@v1.0.0 requires go >= 1.999 \(running go 1.21.0\)'
    12
    13! go mod graph
    14stderr '^go: rsc.io/future@v1.0.0: module rsc.io/future@v1.0.0 requires go >= 1.999 \(running go 1.21.0\)'
    15
    16# TODO(#64008): 'go mod download' without arguments should fail too.
    17
    18
    19# 'go get' should update the main module's go.mod file to a version compatible with the
    20# go version required for rsc.io/future, not fail.
    21go get .
    22stderr '^go: module rsc.io/future@v1.0.0 requires go >= 1.999; switching to go1.999testmod$'
    23stderr '^go: upgraded go 1.21 => 1.999$'
    24stderr '^go: added toolchain go1.999testmod$'
    25
    26
    27# Now, the various 'go mod' subcommands should succeed.
    28
    29go mod download
    30
    31go mod verify
    32
    33go mod graph
    34
    35
    36-- go.mod --
    37module example
    38
    39go 1.21
    40
    41require rsc.io/future v1.0.0
    42-- example.go --
    43package example
    44
    45import _ "rsc.io/future"

View as plain text