-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: update to '@latest' when promoting an indirect dependency to a direct one? #34534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
afaik |
It concerns me that // go.mod
module mod
go 1.13
require sub v0.0.0-00010101000000-000000000000
replace sub => ./sub // main.go
package main
import (
_ "sub"
"cloud.google.com/go/compute/metadata"
)
var _ = metadata.Email
func main() {} [user@localhost ~]$ go build
# mod
./main.go:9:9: undefined: metadata.Email // go.mod
module mod
go 1.13
require (
cloud.google.com/go v0.40.0
sub v0.0.0-00010101000000-000000000000
)
replace sub => ./sub Whereas the following works fine: // go.mod
module mod
go 1.13 // main.go
package main
import "cloud.google.com/go/compute/metadata"
var _ = metadata.Email
func main() {} [user@localhost ~]$ go build // go.mod
module mod
go 1.13
require cloud.google.com/go v0.46.3 |
Found a few more cases that I thought I should note: // main.go
package main
import (
"cloud.google.com/go/compute/metadata"
_ "golang.org/x/oauth2"
)
var _ = metadata.Email
func main() {} one[user@localhost ~]$ go mod init mod
[user@localhost ~]$ go get golang.org/x/oauth2
[user@localhost ~]$ go build
# mod
./main.go:8:9: undefined: metadata.Email two[user@localhost ~]$ go mod init mod
[user@localhost ~]$ go get golang.org/x/oauth2
[user@localhost ~]$ go get cloud.google.com/go
[user@localhost ~]$ go build three[user@localhost ~]$ go mod init mod
[user@localhost ~]$ go build |
CC @jayconrod |
This is an interesting idea, but it would require a substantial amount of refactoring in the module loader in order to notice when we change an indirect dependency to a direct one. (Today that transition only happens when we reduce the complete build list to a minimal one, which occurs after we have finished resolving packages to modules.) |
This also seems potentially dangerous: suppose you had an indirect dependency on D @ v0.1.0, by making it a direct dependency (say going from short to long variable declaration), it triggers an upgrade to 0.2.0 with a breaking api change. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
[user@localhost ~]$ go mod tidy
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: