Skip to content

Commit ae329ab

Browse files
author
Bryan C. Mills
committed
cmd/go: add another test case for package/module ambiguity in 'go get'
For #37438 Change-Id: Iae00ef7f97144e85f4f710cdb3087c2548b4b8f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/256799 Trust: Bryan C. Mills <[email protected]> Trust: Jay Conrod <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 27280d8 commit ae329ab

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Written by hand.
2+
Test module with a root package added in v0.1.0 and removed in v0.2.0.
3+
4+
-- .mod --
5+
module example.net/pkgremoved
6+
7+
go 1.16
8+
-- .info --
9+
{"Version": "v0.1.0"}
10+
-- go.mod --
11+
module example.net/pkgremoved
12+
13+
go 1.16
14+
-- pkgremoved.go --
15+
// Package pkgremoved exists in v0.1.0.
16+
package pkgremoved
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Written by hand.
2+
Test module with a root package added in v0.1.0 and removed in v0.2.0.
3+
4+
-- .mod --
5+
module example.net/pkgremoved
6+
7+
go 1.16
8+
-- .info --
9+
{"Version": "v0.2.0"}
10+
-- go.mod --
11+
module example.net/pkgremoved
12+
13+
go 1.16
14+
-- README.txt --
15+
Package pkgremove was removed in v0.2.0.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Written by hand.
2+
Test module with a root package added in v0.1.0 and removed in v0.2.0.
3+
4+
-- .mod --
5+
module example.net/pkgremoved
6+
7+
go 1.16
8+
-- .info --
9+
{"Version": "v0.2.1"}
10+
-- go.mod --
11+
module example.net/pkgremoved
12+
13+
go 1.16
14+
-- README.txt --
15+
Package pkgremove was removed in v0.2.0.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# example.net/[email protected] refers to a package.
2+
go get -d example.net/[email protected]
3+
4+
go list example.net/pkgremoved
5+
stdout '^example.net/pkgremoved'
6+
7+
# When we resolve a new dependency on example.net/other,
8+
# it will change the meaning of the path "example.net/pkgremoved"
9+
# from a package (at v0.1.0) to only a module (at v0.2.0).
10+
#
11+
# If we simultaneously 'get' that module at the query "patch", the module should
12+
# be upgraded to its patch release (v0.2.1) even though it no longer matches a
13+
# package.
14+
#
15+
# BUG(#37438): Today, the pattern is only interpreted as its initial kind
16+
# (a package), so the 'go get' invocation fails.
17+
18+
! go get -d example.net/pkgremoved@patch example.net/[email protected]
19+
20+
stderr '^go get example.net/pkgremoved@patch: module example.net/pkgremoved@latest found \(v0.2.1\), but does not contain package example.net/pkgremoved$'
21+
22+
23+
-- go.mod --
24+
module example
25+
26+
go 1.16
27+
28+
replace (
29+
example.net/other v0.1.0 => ./other
30+
)
31+
-- other/go.mod --
32+
module example.net/other
33+
34+
go 1.16
35+
36+
require example.net/pkgremoved v0.2.0
37+
-- other/other.go --
38+
package other

0 commit comments

Comments
 (0)