...

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

Documentation: cmd/go/testdata/script

     1# Conflicting replaces in workspace modules returns error that suggests
     2# overriding it in the go.work file.
     3
     4! go list -m example.com/dep
     5stderr 'go: conflicting replacements for example.com/dep@v1.0.0:\n\t'$PWD${/}'dep1\n\t'$PWD${/}'dep2\nuse "go work edit -replace example.com/dep@v1.0.0=\[override\]" to resolve'
     6go work edit -replace example.com/dep@v1.0.0=./dep1
     7go list -m example.com/dep
     8stdout 'example.com/dep v1.0.0 => ./dep1'
     9
    10-- foo --
    11-- go.work --
    12use m
    13use n
    14-- m/go.mod --
    15module example.com/m
    16
    17require example.com/dep v1.0.0
    18replace example.com/dep v1.0.0 => ../dep1
    19-- m/m.go --
    20package m
    21
    22import "example.com/dep"
    23
    24func F() {
    25	dep.G()
    26}
    27-- n/go.mod --
    28module example.com/n
    29
    30require example.com/dep v1.0.0
    31replace example.com/dep v1.0.0 => ../dep2
    32-- n/n.go --
    33package n
    34
    35import "example.com/dep"
    36
    37func F() {
    38	dep.G()
    39}
    40-- dep1/go.mod --
    41module example.com/dep
    42-- dep1/dep.go --
    43package dep
    44
    45func G() {
    46}
    47-- dep2/go.mod --
    48module example.com/dep
    49-- dep2/dep.go --
    50package dep
    51
    52func G() {
    53}

View as plain text