...

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

Documentation: cmd/go/testdata/script

     1# setup
     2env TESTGO_VERSION=go1.99rc1
     3env TESTGO_VERSION_SWITCH=switch
     4
     5# go get go should use the latest Go 1.23
     6cp go.mod.orig go.mod
     7go get go
     8stderr '^go: upgraded go 1.21 => 1.23.9$'
     9grep 'go 1.23.9' go.mod
    10! grep toolchain go.mod
    11
    12# go get go@1.23 should use the latest Go 1.23
    13cp go.mod.orig go.mod
    14go get go@1.23
    15stderr '^go: upgraded go 1.21 => 1.23.9$'
    16grep 'go 1.23.9' go.mod
    17! grep toolchain go.mod
    18
    19# go get go@1.22 should use the latest Go 1.22
    20cp go.mod.orig go.mod
    21go get go@1.22
    22stderr '^go: upgraded go 1.21 => 1.22.9$'
    23grep 'go 1.22.9' go.mod
    24! grep toolchain1 go.mod
    25
    26# go get go@patch should use the latest patch release
    27go get go@1.22.1
    28go get go@patch
    29stderr '^go: upgraded go 1.22.1 => 1.22.9$'
    30grep 'go 1.22.9' go.mod
    31! grep toolchain go.mod
    32
    33# go get go@1.24 does NOT find the release candidate
    34cp go.mod.orig go.mod
    35! go get go@1.24
    36stderr '^go: go@1.24: no matching versions for query "1.24"$'
    37
    38# go get go@1.24rc1 works
    39cp go.mod.orig go.mod
    40go get go@1.24rc1
    41stderr '^go: upgraded go 1.21 => 1.24rc1$'
    42grep 'go 1.24rc1' go.mod
    43! grep toolchain go.mod
    44
    45# go get go@latest finds the latest Go 1.23
    46cp go.mod.orig go.mod
    47go get go@latest
    48stderr '^go: upgraded go 1.21 => 1.23.9$'
    49grep 'go 1.23.9' go.mod
    50! grep toolchain go.mod
    51
    52# Again, with toolchains.
    53
    54go get toolchain@go1.99rc1
    55stderr '^go: added toolchain go1.99rc1$'
    56grep 'go 1.23.9' go.mod
    57grep 'toolchain go1.99rc1' go.mod
    58
    59# go get toolchain should find go1.999testmod.
    60go get toolchain
    61stderr '^go: upgraded toolchain go1.99rc1 => go1.999testmod$'
    62grep 'go 1.23.9' go.mod
    63grep 'toolchain go1.999testmod' go.mod
    64
    65# go get toolchain@go1.23 should use the latest Go 1.23
    66go get toolchain@go1.23
    67stderr '^go: removed toolchain go1.999testmod$'
    68grep 'go 1.23.9' go.mod
    69! grep 'toolchain go1.23.9' go.mod  # implied
    70
    71# go get toolchain@go1.22 should use the latest Go 1.22 and downgrade go.
    72go get toolchain@go1.22
    73stderr '^go: downgraded go 1.23.9 => 1.22.9$'
    74grep 'go 1.22.9' go.mod
    75! grep 'toolchain go1.22.9' go.mod # implied
    76
    77# go get toolchain@patch should use the latest patch release
    78go get toolchain@go1.22.1
    79go get toolchain@patch
    80stderr '^go: added toolchain go1.22.9$'
    81grep 'go 1.22.1' go.mod
    82grep 'toolchain go1.22.9' go.mod
    83go get go@1.22.9 toolchain@none
    84grep 'go 1.22.9' go.mod
    85! grep 'toolchain go1.22.9' go.mod
    86
    87# go get toolchain@go1.24 does NOT find the release candidate
    88! go get toolchain@go1.24
    89stderr '^go: toolchain@go1.24: no matching versions for query "go1.24"$'
    90
    91# go get toolchain@go1.24rc1 works
    92go get toolchain@go1.24rc1
    93stderr '^go: added toolchain go1.24rc1$'
    94grep 'go 1.22.9' go.mod  # no longer implied
    95grep 'toolchain go1.24rc1' go.mod
    96
    97# go get toolchain@latest finds go1.23.9.
    98cp go.mod.orig go.mod
    99go get toolchain@latest
   100stderr '^go: added toolchain go1.23.9$'
   101grep 'go 1.21' go.mod
   102grep 'toolchain go1.23.9' go.mod
   103
   104
   105
   106# Bug fixes.
   107
   108# go get go@garbage should fail but not crash
   109! go get go@garbage
   110! stderr panic
   111stderr '^go: invalid go version garbage$'
   112
   113# go get go@go1.21.0 is OK - we silently correct to 1.21.0
   114go get go@1.19
   115go get go@go1.21.0
   116stderr '^go: upgraded go 1.19 => 1.21.0'
   117
   118# go get toolchain@1.24rc1 is OK too.
   119go get toolchain@1.24rc1
   120stderr '^go: upgraded toolchain go1.23.9 => go1.24rc1$'
   121
   122# go get go@1.21 should work if we are the Go 1.21 language version,
   123# even though there's no toolchain for it.
   124# (Older versions resolve to the latest release in that version, so for example
   125# go get go@1.20 might resolve to 1.20.9, but if we're the devel copy of
   126# Go 1.21, there's no release yet to resolve to, so we resolve to ourselves.)
   127env TESTGO_VERSION=go1.21
   128go get go@1.19 toolchain@none
   129go get go@1.21
   130grep 'go 1.21$' go.mod
   131! grep toolchain go.mod
   132
   133-- go.mod.orig --
   134module m
   135
   136go 1.21

View as plain text