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

     1  # Create basic modules and work space.
     2  env TESTGO_VERSION=go1.50
     3  mkdir m1_22_0
     4  go mod init -C m1_22_0
     5  go mod edit -C m1_22_0 -go=1.22.0 -toolchain=go1.99.0
     6  mkdir m1_22_1
     7  go mod init -C m1_22_1
     8  go mod edit -C m1_22_1 -go=1.22.1 -toolchain=go1.99.1
     9  mkdir m1_24_rc0
    10  go mod init -C m1_24_rc0
    11  go mod edit -C m1_24_rc0 -go=1.24rc0 -toolchain=go1.99.2
    12  
    13  go work init ./m1_22_0 ./m1_22_1
    14  grep '^go 1.50$' go.work
    15  ! grep toolchain go.work
    16  
    17  # work sync with older modules should leave go 1.50 in the go.work.
    18  go work sync
    19  cat go.work
    20  grep '^go 1.50$' go.work
    21  ! grep toolchain go.work
    22  
    23  # work sync with newer modules should update go 1.21 -> 1.22.1 and toolchain -> go1.22.9 in go.work
    24  env TESTGO_VERSION=go1.21
    25  env TESTGO_VERSION_SWITCH=switch
    26  go work edit -go=1.21
    27  grep '^go 1.21$' go.work
    28  ! grep toolchain go.work
    29  env GOTOOLCHAIN=local
    30  ! go work sync
    31  stderr '^go: cannot load module m1_22_0 listed in go.work file: m1_22_0'${/}'go.mod requires go >= 1.22.0 \(running go 1.21; GOTOOLCHAIN=local\)$'
    32  stderr '^go: cannot load module m1_22_1 listed in go.work file: m1_22_1'${/}'go.mod requires go >= 1.22.1 \(running go 1.21; GOTOOLCHAIN=local\)$'
    33  env GOTOOLCHAIN=auto
    34  go work sync
    35  stderr '^go: m1_22_1'${/}'go.mod requires go >= 1.22.1; switching to go1.22.9$'
    36  grep '^go 1.22.1$' go.work
    37  grep '^toolchain go1.22.9$' go.work
    38  
    39  # work sync with newer modules should update go 1.22.1 -> 1.24rc1 and drop toolchain
    40  go work edit -use=./m1_24_rc0
    41  go work sync
    42  stderr '^go: m1_24_rc0'${/}'go.mod requires go >= 1.24rc0; switching to go1.24rc1$'
    43  cat go.work
    44  grep '^go 1.24rc0$' go.work
    45  grep '^toolchain go1.24rc1$' go.work
    46  

View as plain text