...

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

Documentation: cmd/go/testdata/script

     1env TESTGO_VERSION=go1.99
     2
     3! go list -f '{{.Module.GoVersion}}'
     4stderr 'go: updates to go.mod needed'
     5stderr 'go mod tidy'
     6
     7go mod tidy
     8cat go.mod
     9go list -f '{{.Module.GoVersion}}'
    10stdout 1.22
    11
    12# Adding a@v1.0.01 should upgrade to Go 1.23rc1.
    13cp go.mod go.mod1
    14go get example.com/a@v1.0.1
    15stderr '^go: upgraded go 1.22 => 1.23rc1\ngo: upgraded example.com/a v1.0.0 => v1.0.1\ngo: upgraded example.com/b v1.0.0 => v1.0.1$'
    16go list -f '{{.Module.GoVersion}}'
    17stdout 1.23rc1
    18
    19# Repeating the update with go@1.24.0 should use that Go version.
    20cp go.mod1 go.mod
    21go get example.com/a@v1.0.1 go@1.24.0
    22go list -f '{{.Module.GoVersion}}'
    23stdout 1.24.0
    24
    25# Go version-constrained updates should report the problems.
    26cp go.mod1 go.mod
    27! go get example.com/a@v1.0.2 go@1.24.2
    28stderr '^go: example.com/a@v1.0.2 requires go@1.25, not go@1.24.2$'
    29! go get example.com/a@v1.0.2 go@1.26.3
    30stderr '^go: example.com/a@v1.0.2 indirectly requires go@1.27, not go@1.26.3$'
    31go get example.com/a@v1.0.2 go@1.28rc1
    32go list -f '{{.Module.GoVersion}}'
    33stdout 1.28rc1
    34go get go@1.24.2
    35stderr '^go: downgraded go 1.28rc1 => 1.24.2$'
    36stderr '^go: downgraded example.com/a v1.0.2 => v1.0.1$'
    37stderr '^go: downgraded example.com/b v1.0.2 => v1.0.1$'
    38go list -f '{{.Module.GoVersion}}'
    39stdout 1.24.2
    40
    41-- go.mod --
    42module m
    43go 1.21
    44
    45require (
    46	example.com/a v1.0.0
    47	example.com/b v0.9.0
    48)
    49
    50replace example.com/a v1.0.0 => ./a100
    51replace example.com/a v1.0.1 => ./a101
    52replace example.com/a v1.0.2 => ./a102
    53replace example.com/b v1.0.1 => ./b101
    54replace example.com/b v1.0.2 => ./b102
    55replace example.com/b v1.0.0 => ./b100
    56replace example.com/b v0.9.0 => ./b100
    57
    58-- x.go --
    59package m
    60
    61import (
    62	_ "example.com/a"
    63	_ "example.com/b"
    64)
    65
    66-- a100/go.mod --
    67module example.com/a
    68go 1.22
    69
    70require example.com/b v1.0.0
    71
    72-- a100/a.go --
    73package a
    74
    75-- a101/go.mod --
    76// this module is technically invalid, since the dep example.com/b has a newer go line than this module,
    77// but we should still be able to handle it.
    78module example.com/a
    79go 1.22
    80
    81require example.com/b v1.0.1
    82
    83-- a101/a.go --
    84package a
    85
    86-- a102/go.mod --
    87// this module is technically invalid, since the dep example.com/b has a newer go line than this module,
    88// but we should still be able to handle it.
    89module example.com/a
    90go 1.25
    91
    92require example.com/b v1.0.2
    93
    94-- a102/a.go --
    95package a
    96
    97-- b100/go.mod --
    98module example.com/b
    99go 1.22
   100
   101-- b100/b.go --
   102package b
   103
   104-- b101/go.mod --
   105module example.com/b
   106go 1.23rc1
   107
   108-- b101/b.go --
   109package b
   110
   111-- b102/go.mod --
   112module example.com/b
   113go 1.27
   114
   115-- b102/b.go --
   116package b
   117

View as plain text