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

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

View as plain text