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: go mod why fails for replacement modules #30720

Open
rogpeppe opened this issue Mar 10, 2019 · 1 comment
Open

cmd/go: go mod why fails for replacement modules #30720

rogpeppe opened this issue Mar 10, 2019 · 1 comment
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rogpeppe
Copy link
Contributor

$ go version
go version devel +ce7534ff06 Fri Mar 8 13:46:43 2019 +0000 linux/amd64

When one module is replaced by another, go mod why does not acknowledge the replacement module.

Here's an example (https://godoc.org/github.com/rogpeppe/go-internal/cmd/testscript on the below file to reproduce):

It prints "main module does not need module example.com/c, but example.com/c is definitely in use as the replacement for example.com/a which isn't actually used at all.

# This command succeeds; Note: example.com/d is only
# depended on by example.com/c, but not by example.com/a, which is
# never used.
go mod why -m example.com/d

# This command succeeds, even though the program does not
# depend on example.com/a except as a replacement target.
go mod why -m example.com/a
! stdout 'main module does not need module'

# example.com is definitely used (and it's probably important
# the the user know that it is), but this command fails.
go mod why -m example.com/c
! stdout 'main module does not need module'

-- go.mod --
module m

go 1.11

require (
	example.com/a v1.0.0
	example.com/d v1.0.0 // indirect
)

replace example.com/a => example.com/c v1.0.0
-- go.sum --
example.com/c v1.0.0 h1:+JKa2qCailgQdye6M3nnfrb7q748qDLj2NNTEtN2DJs=
example.com/c v1.0.0/go.mod h1:NeOsx/KTizj35klXP3wYh3O0751aAtYrRoX+a6YAye8=
example.com/d v1.0.0 h1:+FTMPN+4iCiTwx9DTGWb788knewVgy4CGwf1SjyLpXY=
example.com/d v1.0.0/go.mod h1:jpRNKJ+rI4SFCFqRJlfe7G4saIJvHgJss1TcTCWmY18=
-- main.go --
package main

import _ "example.com/a"

func main() {
}
-- .gomodproxy/example.com_a_v1.0.0/.info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
-- .gomodproxy/example.com_a_v1.0.0/.mod --
module example.com/a
-- .gomodproxy/example.com_a_v1.0.0/a.go --
package a

import _ "example.com/b"
-- .gomodproxy/example.com_a_v1.0.0/go.mod --
module example.com/a

import _ "example.com/b"
-- .gomodproxy/example.com_b_v1.0.0/.info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
-- .gomodproxy/example.com_b_v1.0.0/.mod --
module example.com/b
-- .gomodproxy/example.com_b_v1.0.0/b.go --
package b
-- .gomodproxy/example.com_b_v1.0.0/go.mod --
module example.com/b
-- .gomodproxy/example.com_c_v1.0.0/.info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
-- .gomodproxy/example.com_c_v1.0.0/.mod --
module example.com/a
-- .gomodproxy/example.com_c_v1.0.0/a.go --
package a

import _ "example.com/d"
-- .gomodproxy/example.com_c_v1.0.0/go.mod --
module example.com/a

require example.com/d v1.0.0
-- .gomodproxy/example.com_d_v1.0.0/.info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
-- .gomodproxy/example.com_d_v1.0.0/.mod --
module example.com/d
-- .gomodproxy/example.com_d_v1.0.0/b.go --
package d
import _ "testing"
-- .gomodproxy/example.com_d_v1.0.0/go.mod --
module example.com/d
@bcmills
Copy link
Contributor

bcmills commented Mar 11, 2019

We'll revisit this after #26904 is addressed.

@bcmills bcmills added this to the Go1.13 milestone Mar 11, 2019
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 11, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants