...

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

Documentation: cmd/go/testdata/script

     1
     2# Create basic modules and work space.
     3# Note that toolchain lines in modules should be completely ignored.
     4env TESTGO_VERSION=go1.50
     5mkdir m1_22_0
     6go mod init -C m1_22_0
     7go mod edit -C m1_22_0 -go=1.22.0 -toolchain=go1.99.0
     8
     9# work init writes the current Go version to the go line
    10go work init
    11grep '^go 1.50$' go.work
    12! grep toolchain go.work
    13
    14# work init with older modules should leave go 1.50 in the go.work.
    15rm go.work
    16go work init ./m1_22_0
    17grep '^go 1.50$' go.work
    18! grep toolchain go.work
    19
    20# work init with newer modules should bump go,
    21# including updating to a newer toolchain as needed.
    22# Because work init writes the current toolchain as the go version,
    23# it writes the bumped go version, not the max of the used modules.
    24env TESTGO_VERSION=go1.21
    25env TESTGO_VERSION_SWITCH=switch
    26rm go.work
    27env GOTOOLCHAIN=local
    28! go work init ./m1_22_0
    29stderr '^go: m1_22_0'${/}'go.mod requires go >= 1.22.0 \(running go 1.21; GOTOOLCHAIN=local\)$'
    30env GOTOOLCHAIN=auto
    31go work init ./m1_22_0
    32stderr '^go: m1_22_0'${/}'go.mod requires go >= 1.22.0; switching to go1.22.9$'
    33cat go.work
    34grep '^go 1.22.9$' go.work
    35! grep toolchain go.work

View as plain text