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

     1  # Regression test for https://golang.org/issue/47979:
     2  #
     3  # An argument to 'go get' that results in an upgrade to a different existing
     4  # root should be allowed, and should not panic the 'go' command.
     5  
     6  cp go.mod go.mod.orig
     7  
     8  
     9  # Transitive upgrades from upgraded roots should not prevent
    10  # 'go get -u' from performing upgrades.
    11  
    12  cp go.mod.orig go.mod
    13  go get -u .
    14  cmp go.mod go.mod.want
    15  
    16  
    17  # 'go get' of a specific version should allow upgrades of
    18  # every dependency (transitively) required by that version,
    19  # including dependencies that are pulled into the module
    20  # graph by upgrading other root requirements
    21  # (in this case, example.net/indirect).
    22  
    23  cp go.mod.orig go.mod
    24  go get example.net/a@v0.2.0
    25  cmp go.mod go.mod.want
    26  
    27  
    28  -- go.mod --
    29  module golang.org/issue47979
    30  
    31  go 1.17
    32  
    33  replace (
    34  	example.net/a v0.1.0 => ./a1
    35  	example.net/a v0.2.0 => ./a2
    36  	example.net/indirect v0.1.0 => ./indirect1
    37  	example.net/indirect v0.2.0 => ./indirect2
    38  	example.net/other v0.1.0 => ./other
    39  	example.net/other v0.2.0 => ./other
    40  )
    41  
    42  require (
    43  	example.net/a v0.1.0
    44  	example.net/other v0.1.0
    45  )
    46  
    47  require example.net/indirect v0.1.0 // indirect
    48  -- go.mod.want --
    49  module golang.org/issue47979
    50  
    51  go 1.17
    52  
    53  replace (
    54  	example.net/a v0.1.0 => ./a1
    55  	example.net/a v0.2.0 => ./a2
    56  	example.net/indirect v0.1.0 => ./indirect1
    57  	example.net/indirect v0.2.0 => ./indirect2
    58  	example.net/other v0.1.0 => ./other
    59  	example.net/other v0.2.0 => ./other
    60  )
    61  
    62  require (
    63  	example.net/a v0.2.0
    64  	example.net/other v0.2.0
    65  )
    66  
    67  require example.net/indirect v0.2.0 // indirect
    68  -- issue.go --
    69  package issue
    70  
    71  import _ "example.net/a"
    72  -- useother/useother.go --
    73  package useother
    74  
    75  import _ "example.net/other"
    76  -- a1/go.mod --
    77  module example.net/a
    78  
    79  go 1.17
    80  
    81  require example.net/indirect v0.1.0
    82  -- a1/a.go --
    83  package a
    84  -- a2/go.mod --
    85  module example.net/a
    86  
    87  go 1.17
    88  
    89  require example.net/indirect v0.2.0
    90  -- a2/a.go --
    91  package a
    92  
    93  import "example.net/indirect"
    94  -- indirect1/go.mod --
    95  module example.net/indirect
    96  
    97  go 1.17
    98  
    99  require example.net/other v0.1.0
   100  -- indirect1/indirect.go --
   101  package indirect
   102  -- indirect2/go.mod --
   103  module example.net/indirect
   104  
   105  go 1.17
   106  
   107  require example.net/other v0.2.0
   108  -- indirect2/indirect.go --
   109  package indirect
   110  
   111  import "example.net/other"
   112  -- other/go.mod --
   113  module example.net/other
   114  
   115  go 1.17
   116  -- other/other.go --
   117  package other
   118  

View as plain text