...

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

Documentation: cmd/go/testdata/script

     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
    15go mod tidy
    16cmp go.mod go.mod.tidy
    17
    18-- go.mod --
    19module example.net/a
    20
    21go 1.16
    22
    23require (
    24	example.net/b v0.1.0
    25	example.net/d v0.1.0
    26)
    27
    28replace (
    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 --
    35module example.net/a
    36
    37go 1.16
    38
    39require (
    40	example.net/c v0.2.0 // indirect
    41	example.net/d v0.1.0
    42)
    43
    44replace (
    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 --
    51package a
    52
    53import _ "example.net/d"
    54
    55-- b/go.mod --
    56module example.net/b
    57
    58go 1.16
    59
    60require example.net/c v0.2.0
    61-- b/b.go --
    62package b
    63
    64import _ "example.net/c"
    65
    66-- c/go.mod --
    67module example.net/c
    68
    69go 1.16
    70-- c/c.go --
    71package c
    72
    73-- d/go.mod --
    74module example.net/d
    75
    76go 1.16
    77
    78require example.net/c v0.1.0
    79-- d/d.go --
    80package d
    81
    82import _ "example.net/c"

View as plain text