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 go1.99rc1' 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 go1.99rc1' 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 'toolchain go1.99rc1' 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 go1.99rc1' 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 go1.99rc1' 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 go1.99rc1' go.mod
    51  
    52  # Again, with toolchains.
    53  
    54  # go get toolchain should find go1.999testmod.
    55  go get toolchain
    56  stderr '^go: upgraded toolchain go1.99rc1 => go1.999testmod$'
    57  grep 'go 1.23.9' go.mod
    58  grep 'toolchain go1.999testmod' go.mod
    59  
    60  # go get toolchain@go1.23 should use the latest Go 1.23
    61  go get toolchain@go1.23
    62  stderr '^go: removed toolchain go1.999testmod$'
    63  grep '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.
    67  go get toolchain@go1.22
    68  stderr '^go: downgraded go 1.23.9 => 1.22.9$'
    69  grep '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
    73  go get toolchain@go1.22.1
    74  go get toolchain@patch
    75  stderr '^go: added toolchain go1.22.9$'
    76  grep 'go 1.22.1' go.mod
    77  grep 'toolchain go1.22.9' go.mod
    78  go get go@1.22.9 toolchain@none
    79  grep '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
    84  stderr '^go: toolchain@go1.24: no matching versions for query "go1.24"$'
    85  
    86  # go get toolchain@go1.24rc1 works
    87  go get toolchain@go1.24rc1
    88  stderr '^go: added toolchain go1.24rc1$'
    89  grep 'go 1.22.9' go.mod  # no longer implied
    90  grep 'toolchain go1.24rc1' go.mod
    91  
    92  # go get toolchain@latest finds go1.999testmod.
    93  cp go.mod.orig go.mod
    94  go get toolchain@latest
    95  stderr '^go: added toolchain go1.999testmod$'
    96  grep 'go 1.21' go.mod
    97  grep '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
   104  stderr '^go: invalid go version garbage$'
   105  
   106  # go get go@go1.21.0 is OK - we silently correct to 1.21.0
   107  go get go@1.19
   108  go get go@go1.21.0
   109  stderr '^go: upgraded go 1.19 => 1.21.0'
   110  
   111  # go get toolchain@1.24rc1 is OK too.
   112  go get toolchain@1.24rc1
   113  stderr '^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.)
   120  env TESTGO_VERSION=go1.21
   121  go get go@1.19 toolchain@none
   122  go get go@1.21
   123  grep 'go 1.21$' go.mod
   124  ! grep toolchain go.mod
   125  
   126  -- go.mod.orig --
   127  module m
   128  
   129  go 1.21
   130  

View as plain text