-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: annotate versions in vendor/modules.txt
In order to prevent edit wars with previous cmd/go releases, the new version annotations are only included if the main module specifies 'go 1.17' or higher. Fixes #36876 Change-Id: Iba15e47dd1ac2c16d754679a9b501db4069fa250 Reviewed-on: https://go-review.googlesource.com/c/go/+/315409 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
- Loading branch information
Bryan C. Mills
committed
Apr 30, 2021
1 parent
7dedc23
commit c3365ad
Showing
7 changed files
with
154 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
|
||
[short] skip | ||
|
||
go mod init example.com/foo | ||
go mod edit -replace=example.com/[email protected]=./use113 | ||
|
||
go mod vendor | ||
|
@@ -20,7 +19,10 @@ go mod vendor | |
! grep 1.13 vendor/modules.txt | ||
go build . | ||
|
||
-- go.mod -- | ||
module example.com/foo | ||
|
||
go 1.16 | ||
-- foo.go -- | ||
package foo | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# https://golang.org/issue/36876: As of Go 1.17, vendor/modules.txt should | ||
# indicate the language version used by each dependency. | ||
|
||
[short] skip | ||
|
||
|
||
# Control case: without a vendor directory, need117 builds and bad114 doesn't. | ||
|
||
go build example.net/need117 | ||
! go build example.net/bad114 | ||
stderr '^bad114[/\\]bad114.go:15:2: duplicate method Y$' | ||
|
||
|
||
# With a vendor/modules.txt lacking language versions, the world is topsy-turvy. | ||
# Things that ought to build shouldn't, and things that shouldn't build do. | ||
|
||
go mod vendor | ||
go build example.net/bad114 | ||
! go build example.net/need117 | ||
stderr '^vendor[/\\]example\.net[/\\]need117[/\\]need117.go:5:18: .*\n\tconversion of slices to array pointers only supported as of -lang=go1\.17' | ||
|
||
|
||
# Upgrading the main module to 1.17 adds version annotations. | ||
# Then everything is once again consistent with the non-vendored world. | ||
|
||
go mod edit -go=1.17 | ||
go mod vendor | ||
go build example.net/need117 | ||
! go build example.net/bad114 | ||
stderr '^vendor[/\\]example\.net[/\\]bad114[/\\]bad114.go:15:2: duplicate method Y$' | ||
|
||
|
||
-- go.mod -- | ||
module example.net/m | ||
|
||
go 1.16 | ||
|
||
require ( | ||
example.net/bad114 v0.1.0 | ||
example.net/need117 v0.1.0 | ||
) | ||
|
||
replace ( | ||
example.net/bad114 v0.1.0 => ./bad114 | ||
example.net/need117 v0.1.0 => ./need117 | ||
) | ||
-- m.go -- | ||
package m | ||
|
||
import _ "example.net/bad114" | ||
import _ "example.net/need117" | ||
|
||
-- bad114/go.mod -- | ||
// Module bad114 requires Go 1.14 or higher, but declares Go 1.13. | ||
module example.net/bad114 | ||
|
||
go 1.13 | ||
-- bad114/bad114.go -- | ||
package bad114 | ||
|
||
type XY interface { | ||
X() | ||
Y() | ||
} | ||
|
||
type YZ interface { | ||
Y() | ||
Z() | ||
} | ||
|
||
type XYZ interface { | ||
XY | ||
YZ | ||
} | ||
|
||
-- need117/go.mod -- | ||
// Module need117 requires Go 1.17 or higher. | ||
module example.net/need117 | ||
|
||
go 1.17 | ||
-- need117/need117.go -- | ||
package need117 | ||
|
||
func init() { | ||
s := make([]byte, 4) | ||
_ = (*[4]byte)(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters