...

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
    10grep 'toolchain go1.99rc1' 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
    17grep 'toolchain go1.99rc1' 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
    24grep 'toolchain go1.99rc1' 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
    31grep 'toolchain go1.99rc1' 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
    43grep 'toolchain go1.99rc1' 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
    50grep 'toolchain go1.99rc1' go.mod
    51
    52# Again, with toolchains.
    53
    54# go get toolchain should find go1.999testmod.
    55go get toolchain
    56stderr '^go: upgraded toolchain go1.99rc1 => go1.999testmod$'
    57grep 'go 1.23.9' go.mod
    58grep 'toolchain go1.999testmod' go.mod
    59
    60# go get toolchain@go1.23 should use the latest Go 1.23
    61go get toolchain@go1.23
    62stderr '^go: removed toolchain go1.999testmod$'
    63grep 'go 1.23.9' go.mod
    64! grep 'toolchain go1.23.9' go.mod  # implied
    65
    66# go get toolchain@go1.22 should use the latest Go 1.22 and downgrade go.
    67go get toolchain@go1.22
    68stderr '^go: downgraded go 1.23.9 => 1.22.9$'
    69grep 'go 1.22.9' go.mod
    70! grep 'toolchain go1.22.9' go.mod # implied
    71
    72# go get toolchain@patch should use the latest patch release
    73go get toolchain@go1.22.1
    74go get toolchain@patch
    75stderr '^go: added toolchain go1.22.9$'
    76grep 'go 1.22.1' go.mod
    77grep 'toolchain go1.22.9' go.mod
    78go get go@1.22.9 toolchain@none
    79grep 'go 1.22.9' go.mod
    80! grep 'toolchain go1.22.9' go.mod
    81
    82# go get toolchain@go1.24 does NOT find the release candidate
    83! go get toolchain@go1.24
    84stderr '^go: toolchain@go1.24: no matching versions for query "go1.24"$'
    85
    86# go get toolchain@go1.24rc1 works
    87go get toolchain@go1.24rc1
    88stderr '^go: added toolchain go1.24rc1$'
    89grep 'go 1.22.9' go.mod  # no longer implied
    90grep 'toolchain go1.24rc1' go.mod
    91
    92# go get toolchain@latest finds go1.999testmod.
    93cp go.mod.orig go.mod
    94go get toolchain@latest
    95stderr '^go: added toolchain go1.999testmod$'
    96grep 'go 1.21' go.mod
    97grep 'toolchain go1.999testmod' go.mod
    98
    99# Bug fixes.
   100
   101# go get go@garbage should fail but not crash
   102! go get go@garbage
   103! stderr panic
   104stderr '^go: invalid go version garbage$'
   105
   106# go get go@go1.21.0 is OK - we silently correct to 1.21.0
   107go get go@1.19
   108go get go@go1.21.0
   109stderr '^go: upgraded go 1.19 => 1.21.0'
   110
   111# go get toolchain@1.24rc1 is OK too.
   112go get toolchain@1.24rc1
   113stderr '^go: downgraded toolchain go1.999testmod => go1.24rc1$'
   114
   115# go get go@1.21 should work if we are the Go 1.21 language version,
   116# even though there's no toolchain for it.
   117# (Older versions resolve to the latest release in that version, so for example
   118# go get go@1.20 might resolve to 1.20.9, but if we're the devel copy of
   119# Go 1.21, there's no release yet to resolve to, so we resolve to ourselves.)
   120env TESTGO_VERSION=go1.21
   121go get go@1.19 toolchain@none
   122go get go@1.21
   123grep 'go 1.21$' go.mod
   124! grep toolchain go.mod
   125
   126-- go.mod.orig --
   127module m
   128
   129go 1.21

View as plain text