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

     1  # Check that go line in go.work is always >= go line of used modules.
     2  
     3  # Using an old Go version, fails during module loading, but we rewrite the error to the
     4  # same one a switching version would use, without the auto-switch.
     5  # This is a misconfigured system that should not arise in practice.
     6  env TESTGO_VERSION=go1.21.1
     7  env TESTGO_VERSION_SWITCH=switch
     8  cp go.work go.work.orig
     9  ! go list
    10  stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to update it:\n\tgo work use$'
    11  go work use
    12  go list
    13  
    14  # Using a new enough Go version, fails later and can suggest 'go work use'.
    15  env TESTGO_VERSION=go1.21.2
    16  env TESTGO_VERSION_SWITCH=switch
    17  cp go.work.orig go.work
    18  ! go list
    19  stderr '^go: module . listed in go.work file requires go >= 1.21.2, but go.work lists go 1.21.1; to update it:\n\tgo work use$'
    20  
    21  # go work use fixes the problem.
    22  go work use
    23  go list
    24  
    25  -- go.work --
    26  go 1.21.1
    27  use .
    28  
    29  -- go.mod --
    30  module m
    31  go 1.21.2
    32  
    33  -- p.go --
    34  package p
    35  

View as plain text