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: module shows as "indirect" in go.mod after being fetched with go get as a direct dependency #61480

Closed
shina1024 opened this issue Jul 20, 2023 · 3 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@shina1024
Copy link

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

$ go version
go version go1.20.6 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\UserName\AppData\Local\go-build
set GOENV=C:\Users\UserName\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\UserName\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\UserName\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.6
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\UserName\AppData\Local\Temp\go-build144073124=/tmp/go-build -gno-record-gcc-switches
PS C:\Users\UserName>

What did you do?

  1. I added "github.com/inancgumus/screen" to my imports in the Go source code.
  2. I ran the command go get github.com/inancgumus/screen.

What did you expect to see?

I expected that "github.com/inancgumus/screen" would appear as a direct dependency in the go.mod file.

What did you see instead?

After running the go get command, the following line appeared in the go.mod file:
require github.com/inancgumus/screen v0.0.0-20190314163918-06e984b86ed3 // indirect

However, after running go mod tidy, the "indirect" marking was removed.

Could you please advise if this is the expected behavior? If this is actually expected and is not a bug, I apologize for any misunderstanding. Thank you for your assistance.

@heschi heschi changed the title affected/package: mod Package shows as "indirect" in go.mod after being fetched with go get as a direct dependency cmd/go: module shows as "indirect" in go.mod after being fetched with go get as a direct dependency Jul 20, 2023
@heschi
Copy link
Contributor

heschi commented Jul 20, 2023

cc @bcmills @matloob

@heschi heschi added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jul 20, 2023
@heschi heschi added this to the Backlog milestone Jul 20, 2023
@bcmills
Copy link
Contributor

bcmills commented Jul 20, 2023

Could you please advise if this is the expected behavior?

Yes, this is expected. When you run go get github.com/inancgumus/screen, it loads only the package you requested and the packages it transitively imports. That command doesn't have enough information to know whether you actually added an import of that package.

If you would like the new packages to be marked direct from the start, you can use go get -t ./... instead of go get github.com/inancgumus/screen. That will add any packages needed for go test ./... to succeed, and — because those dependencies are found by scanning the imports of ./... in your module — it will mark them as direct.

@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2023
@shina1024
Copy link
Author

Thanks @bcmills! I appreciate your explanation.

@golang golang locked and limited conversation to collaborators Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

4 participants