| 1 |
go list -m all |
| 2 |
stdout '^example.net/m v0.1.0 ' |
| 3 |
! stdout '^example.net/m/p ' |
| 4 |
cp 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/[email protected] |
| 12 |
stderr '^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' |
| 13 |
cmp 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. |
| 18 |
go get example.net/[email protected] example.net/m/[email protected] |
| 19 |
|
| 20 |
go list -m all |
| 21 |
stdout '^example.net/m v0.2.0 ' |
| 22 |
stdout '^example.net/m/p v1.0.0 ' |
| 23 |
|
| 24 |
-- go.mod -- |
| 25 |
module example.net/importer |
| 26 |
|
| 27 |
go 1.16 |
| 28 |
|
| 29 |
require ( |
| 30 |
example.net/m v0.1.0 |
| 31 |
) |
| 32 |
|
| 33 |
replace ( |
| 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 -- |
| 39 |
package importer |
| 40 |
import _ "example.net/m/p" |
| 41 |
-- m1/go.mod -- |
| 42 |
module example.net/m |
| 43 |
|
| 44 |
go 1.16 |
| 45 |
-- m1/p/p.go -- |
| 46 |
package p |
| 47 |
-- m2/go.mod -- |
| 48 |
module example.net/m |
| 49 |
|
| 50 |
go 1.16 |
| 51 |
-- m2/README.txt -- |
| 52 |
Package p has been moved to module …/m/p. |
| 53 |
Module …/m/p does not require any version of module …/m. |
| 54 |
|
| 55 |
-- p0/go.mod -- |
| 56 |
module example.net/m/p |
| 57 |
|
| 58 |
go 1.16 |
| 59 |
-- p0/p.go -- |
| 60 |
package p |