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

go mod why X installs X to go.mod? #39082

Closed
ORESoftware opened this issue May 14, 2020 · 2 comments
Closed

go mod why X installs X to go.mod? #39082

ORESoftware opened this issue May 14, 2020 · 2 comments

Comments

@ORESoftware
Copy link

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

go version go1.14 darwin/amd64

Does this issue reproduce with the latest release?

More or less.

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

go env Output

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/alex/Library/Caches/go-build"
GOENV="/Users/alex/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/alex/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/local/Cellar/go/1.14/libexec"
GOSUMDB="off"
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/alex/go/src/github.com/channelmeter/cp-go-api/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/qh/l8tr6tfd3gv7fmdg0b5z0p340000gn/T/go-build287184497=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I ran:

 go mod why github.com/DATA-DOG/go-sqlmock 

and it added that dep to my go.mod file. I didn't expect it to add it to the file, if it wasn't already there.

@ORESoftware ORESoftware changed the title go mod why XXX installs XXX to go.mod? go mod why X installs X to go.mod? May 14, 2020
@mvdan
Copy link
Member

mvdan commented May 15, 2020

I think you wanted go mod why -m instead. go mod why works on packages, so if it's given a package that doesn't belong in any of the modules it knows about, it must then resolve that new module (thus adding it to go.mod).

@mvdan mvdan added the modules label May 15, 2020
@bcmills
Copy link
Contributor

bcmills commented May 18, 2020

Duplicate of #26977

@bcmills bcmills marked this as a duplicate of #26977 May 18, 2020
@bcmills bcmills closed this as completed May 18, 2020
@golang golang locked and limited conversation to collaborators May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants