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

     1  # https://golang.org/issue/45952: 'go mod tidy' in an eager module failed due
     2  # to an erroneous check on root completeness.
     3  #
     4  # Per the issue report:
     5  # > It may have to do with:
     6  # >
     7  # > package A imports package B in go.mod, which imports package C in its own go.mod
     8  # > package A drops direct dependency on package B …
     9  #
    10  # We infer from that that package C is still needed by some other indirect
    11  # dependency, and must be at a higher version than what is required by that
    12  # dependency (or else no new root would be needed). An additional package D
    13  # in its own module satisfies that condition, reproducing the bug.
    14  
    15  go mod tidy
    16  cmp go.mod go.mod.tidy
    17  
    18  -- go.mod --
    19  module example.net/a
    20  
    21  go 1.16
    22  
    23  require (
    24  	example.net/b v0.1.0
    25  	example.net/d v0.1.0
    26  )
    27  
    28  replace (
    29  	example.net/b v0.1.0 => ./b
    30  	example.net/c v0.1.0 => ./c
    31  	example.net/c v0.2.0 => ./c
    32  	example.net/d v0.1.0 => ./d
    33  )
    34  -- go.mod.tidy --
    35  module example.net/a
    36  
    37  go 1.16
    38  
    39  require (
    40  	example.net/c v0.2.0 // indirect
    41  	example.net/d v0.1.0
    42  )
    43  
    44  replace (
    45  	example.net/b v0.1.0 => ./b
    46  	example.net/c v0.1.0 => ./c
    47  	example.net/c v0.2.0 => ./c
    48  	example.net/d v0.1.0 => ./d
    49  )
    50  -- a.go --
    51  package a
    52  
    53  import _ "example.net/d"
    54  
    55  -- b/go.mod --
    56  module example.net/b
    57  
    58  go 1.16
    59  
    60  require example.net/c v0.2.0
    61  -- b/b.go --
    62  package b
    63  
    64  import _ "example.net/c"
    65  
    66  -- c/go.mod --
    67  module example.net/c
    68  
    69  go 1.16
    70  -- c/c.go --
    71  package c
    72  
    73  -- d/go.mod --
    74  module example.net/d
    75  
    76  go 1.16
    77  
    78  require example.net/c v0.1.0
    79  -- d/d.go --
    80  package d
    81  
    82  import _ "example.net/c"
    83  

View as plain text