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

rogpeppe opened this issue Mar 10, 2019 · 1 comment


Copy link

commented Mar 10, 2019

$ 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 ( on the below file to reproduce):

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

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

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

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

-- go.mod --
module m

go 1.11

require ( v1.0.0 v1.0.0 // indirect

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

import _ ""

func main() {
-- .gomodproxy/example.com_a_v1.0.0/.info --
-- .gomodproxy/example.com_a_v1.0.0/.mod --
-- .gomodproxy/example.com_a_v1.0.0/a.go --
package a

import _ ""
-- .gomodproxy/example.com_a_v1.0.0/go.mod --

import _ ""
-- .gomodproxy/example.com_b_v1.0.0/.info --
-- .gomodproxy/example.com_b_v1.0.0/.mod --
-- .gomodproxy/example.com_b_v1.0.0/b.go --
package b
-- .gomodproxy/example.com_b_v1.0.0/go.mod --
-- .gomodproxy/example.com_c_v1.0.0/.info --
-- .gomodproxy/example.com_c_v1.0.0/.mod --
-- .gomodproxy/example.com_c_v1.0.0/a.go --
package a

import _ ""
-- .gomodproxy/example.com_c_v1.0.0/go.mod --

require v1.0.0
-- .gomodproxy/example.com_d_v1.0.0/.info --
-- .gomodproxy/example.com_d_v1.0.0/.mod --
-- .gomodproxy/example.com_d_v1.0.0/b.go --
package d
import _ "testing"
-- .gomodproxy/example.com_d_v1.0.0/go.mod --
@rogpeppe rogpeppe added the modules label Mar 10, 2019

This comment has been minimized.

Copy link

commented Mar 11, 2019

We'll revisit this after #26904 is addressed.

@bcmills bcmills added this to the Go1.13 milestone 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
None yet
4 participants
You can’t perform that action at this time.