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' should return module results even without '-m' #37761

Open
meling opened this issue Mar 9, 2020 · 2 comments
Open

cmd/go: 'go mod why' should return module results even without '-m' #37761

meling opened this issue Mar 9, 2020 · 2 comments
Labels
modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@meling
Copy link

meling commented Mar 9, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/meling/Library/Caches/go-build"
GOENV="/Users/meling/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/meling/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/meling/work/gorums/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xd/1g4dygzx1_g3thyggq8qllh40000gn/T/go-build624263632=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Ran go mod why without -m flag when the argument was a module instead of a package, leading to the message:

% go mod why github.com/labstack/echo-contrib
# github.com/labstack/echo-contrib
(main module does not need package github.com/labstack/echo-contrib)

This is unhelpful and has bitten me many times now. How do I know whether or not something in my go.mod file is a package or module? This is confusing to me and probably others.

What did you expect to see?

I expected to see which package or module was using the relevant module (or package):

% go mod why -m github.com/labstack/echo-contrib
# github.com/labstack/echo-contrib
github.com/autograde/aguis/web
github.com/labstack/echo-contrib/session

Proposal

I propose that the go mod why command should return a result either way. If the tool finds that the main module does not depend on the supplied package it should check if it depends on a corresponding module instead, obviating the need for the -m flag.

@bcmills
Copy link
Contributor

bcmills commented Mar 9, 2020

Duplicate of #27900

@bcmills bcmills marked this as a duplicate of #27900 Mar 9, 2020
@bcmills bcmills closed this as completed Mar 9, 2020
@bcmills bcmills marked this as not a duplicate of #27900 Mar 9, 2020
@bcmills bcmills reopened this Mar 9, 2020
@bcmills
Copy link
Contributor

bcmills commented Mar 9, 2020

Actually, this one is slightly different, I think.

(Same general idea, though: go mod why should volunteer relevant information even when it doesn't find the exact dependency queried.)

@bcmills bcmills added modules NeedsFix The path to resolution is known, but the work has not been done. labels Mar 9, 2020
@bcmills bcmills added this to the Backlog milestone Mar 9, 2020
@bcmills bcmills changed the title go/cmd: go mod why should return result for both package and module cmd/go: 'go mod why' should return module results even without '-m' Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants