Skip to content
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

cmd/go: do not resolve missing imports in 'go mod why' #26977

Closed
FiloSottile opened this issue Aug 14, 2018 · 4 comments
Closed

cmd/go: do not resolve missing imports in 'go mod why' #26977

FiloSottile opened this issue Aug 14, 2018 · 4 comments
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@FiloSottile
Copy link
Contributor

Starting at https://github.com/FiloSottile/mkcert/tree/44af1b655699715a3468685d46b5ca530469a0c4

$ GO111MODULE=on go1.11rc1 mod init
go: creating new go.mod: module github.com/FiloSottile/mkcert
go: copying requirements from Gopkg.lock

$ GO111MODULE=on go1.11rc1 mod vendor
go: finding github.com/DHowett/go-plist v0.0.0-20180609054337-500bd5b9081b
go: finding software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237
go: finding golang.org/x/net v0.0.0-20180627171509-e514e69ffb8b
go: finding golang.org/x/text v0.3.0
go: downloading software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237
go: downloading golang.org/x/net v0.0.0-20180627171509-e514e69ffb8b
go: downloading github.com/DHowett/go-plist v0.0.0-20180609054337-500bd5b9081b
go: downloading golang.org/x/text v0.3.0

$ cat go.mod
module github.com/FiloSottile/mkcert

require (
	github.com/DHowett/go-plist v0.0.0-20180609054337-500bd5b9081b
	golang.org/x/net v0.0.0-20180627171509-e514e69ffb8b
	golang.org/x/text v0.3.0 // indirect
	software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237
)

So far so good. It builds, and everything works.

Then I run go mod why (which does not answer me because I want #26968).

$ GO111MODULE=on go1.11rc1 mod why golang.org/x/text
go: finding howett.net/plist latest
go: downloading howett.net/plist v0.0.0-20180609054337-500bd5b9081b
# golang.org/x/text
(main module does not need package golang.org/x/text)

And now a new line appeared in the go.mod, which does not seem something I should expect?

diff --git a/go.mod b/go.mod
index 458640f..cd3792e 100644
--- a/go.mod
+++ b/go.mod
@@ -4,5 +4,6 @@ require (
        github.com/DHowett/go-plist v0.0.0-20180609054337-500bd5b9081b
        golang.org/x/net v0.0.0-20180627171509-e514e69ffb8b
        golang.org/x/text v0.3.0 // indirect
+       howett.net/plist v0.0.0-20180609054337-500bd5b9081b // indirect
        software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237
 )
diff --git a/go.sum b/go.sum
index 68659a5..1f591aa 100644
--- a/go.sum
+++ b/go.sum
@@ -4,5 +4,7 @@ golang.org/x/net v0.0.0-20180627171509-e514e69ffb8b h1:oXs/nlnyk1ue6g+mFGEHIuIaQ
 golang.org/x/net v0.0.0-20180627171509-e514e69ffb8b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+howett.net/plist v0.0.0-20180609054337-500bd5b9081b h1:r4LwkXZhdblHVSgAvfRjsFpQBorl6S9pAH+AOHVs+28=
+howett.net/plist v0.0.0-20180609054337-500bd5b9081b/go.mod h1:jInWmjR7JRkkon4jlLXDZGVEeY/wo3kOOJEWYhNE+9Y=
 software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237 h1:iAEkCBPbRaflBgZ7o9gjVUuWuvWeV4sytFWg9o+Pj2k=
 software.sslmate.com/src/go-pkcs12 v0.0.0-20180114231543-2291e8f0f237/go.mod h1:/xvNRWUqm0+/ZMiF4EX00vrSCMsE4/NHb+Pt3freEeQ=
@FiloSottile FiloSottile added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Aug 14, 2018
@FiloSottile FiloSottile added this to the Go1.11 milestone Aug 14, 2018
@rsc
Copy link
Contributor

rsc commented Aug 17, 2018

Maybe we can revisit in Go 1.12.

@rsc rsc modified the milestones: Go1.11, Go1.12 Aug 17, 2018
@dmitris
Copy link
Contributor

dmitris commented Oct 8, 2018

seeing the same issue (with fo1.11.1), go mod why <pkg> functions as go mod tidy - even though there seems to be nothing in the go mod help tidy regarding that, and as a user I don't expect a "why" query to have silent side-effect modifications on go.mod

@bcmills bcmills self-assigned this Nov 14, 2018
@andybons andybons modified the milestones: Go1.12, Go1.13 Feb 12, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@bcmills bcmills changed the title cmd/go: go mod why adds a go.mod line cmd/go: do not resolve missing imports in 'go mod why' Sep 23, 2019
@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 23, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 23, 2019

I think the fix here is to make go mod why simply skip over imports that are not satisfied by any existing module dependency.

That would also address the problem in #34432, in which an error in an unresolved dependency prevents go mod why from producing useful output for an unrelated module.

CC @jayconrod

@gopherbot
Copy link

Change https://golang.org/cl/255938 mentions this issue: cmd/go/internal/modget: consolidate Load entrypoints

@golang golang locked and limited conversation to collaborators Sep 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants