...

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

Documentation: cmd/go/testdata/script

     1go list -m all
     2stdout '^example.net/m v0.1.0 '
     3! stdout '^example.net/m/p '
     4cp go.mod go.mod.orig
     5
     6# Upgrading example.net/m/p without also upgrading example.net/m
     7# causes the import of package example.net/m/p to be ambiguous.
     8#
     9# TODO(#27899): Should we automatically upgrade example.net/m to v0.2.0
    10# to resolve the conflict?
    11! go get example.net/m/p@v1.0.0
    12stderr '^go: example.net/m/p: ambiguous import: found package example.net/m/p in multiple modules:\n\texample.net/m v0.1.0 \(.*[/\\]m1[/\\]p\)\n\texample.net/m/p v1.0.0 \(.*[/\\]p0\)\n\z'
    13cmp go.mod go.mod.orig
    14
    15# Upgrading both modules simultaneously resolves the ambiguous upgrade.
    16# Note that this command line mixes a module path (example.net/m)
    17# and a package path (example.net/m/p) in the same command.
    18go get example.net/m@v0.2.0 example.net/m/p@v1.0.0
    19
    20go list -m all
    21stdout '^example.net/m v0.2.0 '
    22stdout '^example.net/m/p v1.0.0 '
    23
    24-- go.mod --
    25module example.net/importer
    26
    27go 1.16
    28
    29require (
    30	example.net/m v0.1.0
    31)
    32
    33replace (
    34	example.net/m v0.1.0 => ./m1
    35	example.net/m v0.2.0 => ./m2
    36	example.net/m/p v1.0.0 => ./p0
    37)
    38-- importer.go --
    39package importer
    40import _ "example.net/m/p"
    41-- m1/go.mod --
    42module example.net/m
    43
    44go 1.16
    45-- m1/p/p.go --
    46package p
    47-- m2/go.mod --
    48module example.net/m
    49
    50go 1.16
    51-- m2/README.txt --
    52Package p has been moved to module …/m/p.
    53Module …/m/p does not require any version of module …/m.
    54
    55-- p0/go.mod --
    56module example.net/m/p
    57
    58go 1.16
    59-- p0/p.go --
    60package p

View as plain text