Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/testdata/script

     1  # https://golang.org/issue/46142: 'go mod tidy' should error out if the version
     2  # in the go.mod file is newer than the most recent supported version.
     3  
     4  cp go.mod go.mod.orig
     5  
     6  
     7  # If the go.mod file specifies an unsupported Go version, 'go mod tidy' should
     8  # refuse to edit it: we don't know what a tidy go.mod file for that version
     9  # would look like.
    10  
    11  ! go mod tidy
    12  stderr 'go mod tidy: go.mod file indicates go 2000.0, but maximum supported version is '$goversion'$'
    13  cmp go.mod go.mod.orig
    14  
    15  
    16  # The -e flag should push past the error and edit the file anyway,
    17  # but preserve the too-high version.
    18  
    19  cp go.mod.orig go.mod
    20  go mod tidy -e
    21  stderr 'go mod tidy: go.mod file indicates go 2000.0, but maximum supported version is '$goversion'$'
    22  cmp go.mod go.mod.tidy
    23  
    24  
    25  # Explicitly switching to a supported version should suppress the error completely.
    26  
    27  cp go.mod.orig go.mod
    28  go mod tidy -go=1.17
    29  ! stderr 'maximum supported version'
    30  go mod edit -go=1.17 go.mod.tidy
    31  cmp go.mod go.mod.tidy
    32  
    33  
    34  -- go.mod --
    35  module example.net/from/the/future
    36  
    37  go 2000.0
    38  
    39  replace example.net/m v0.0.0 => ./m
    40  -- go.mod.tidy --
    41  module example.net/from/the/future
    42  
    43  go 2000.0
    44  
    45  replace example.net/m v0.0.0 => ./m
    46  
    47  require example.net/m v0.0.0
    48  -- x.go --
    49  package x
    50  
    51  import "example.net/m"
    52  -- m/go.mod --
    53  module example.net/m
    54  
    55  go 1.17
    56  -- m/m.go --
    57  package m
    58  

View as plain text