...

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

Documentation: cmd/go/testdata/script

     1# This test illustrates a case where downgrading one module may upgrade another.
     2# Compare to the downcross2 test case in cmd/go/internal/mvs/mvs_test.go.
     3
     4# The initial package import graph used in this test looks like:
     5#
     6# a ---- b ---- d
     7#
     8# The module dependency graph originally looks like:
     9#
    10# a ---- b.2 ---- d.2
    11#
    12# b.1 ---- c.1
    13#
    14# If we downgrade module d to version 1, we must downgrade b as well.
    15# If that downgrade selects b version 1, we will add a new dependency on module c.
    16
    17cp go.mod go.mod.orig
    18go mod tidy
    19cmp go.mod.orig go.mod
    20
    21go get example.com/d@v0.1.0
    22go list -m all
    23stdout '^example.com/b v0.1.0 '
    24stdout '^example.com/c v0.1.0 '
    25stdout '^example.com/d v0.1.0 '
    26
    27-- go.mod --
    28module example.com/a
    29
    30go 1.15
    31
    32require example.com/b v0.2.0
    33
    34replace (
    35	example.com/b v0.1.0 => ./b1
    36	example.com/b v0.2.0 => ./b2
    37	example.com/c v0.1.0 => ./c
    38	example.com/d v0.1.0 => ./d
    39	example.com/d v0.2.0 => ./d
    40)
    41-- a.go --
    42package a
    43
    44import _ "example.com/b"
    45
    46-- b1/go.mod --
    47module example.com/b
    48
    49go 1.15
    50
    51require example.com/c v0.1.0
    52-- b1/b.go --
    53package b
    54
    55import _ "example.com/c"
    56
    57-- b2/go.mod --
    58module example.com/b
    59
    60go 1.15
    61
    62require example.com/d v0.2.0
    63-- b2/b.go --
    64package b
    65
    66import _ "example.com/d"
    67
    68-- c/go.mod --
    69module example.com/c
    70
    71go 1.15
    72
    73-- c/c.go --
    74package c
    75
    76-- d/go.mod --
    77module example.com/d
    78
    79go 1.15
    80-- d/d.go --
    81package d

View as plain text