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 list -find -json outputs a non empty Package.Deps #46092

Closed
perillo opened this issue May 10, 2021 · 4 comments
Closed

cmd/go: go list -find -json outputs a non empty Package.Deps #46092

perillo opened this issue May 10, 2021 · 4 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@perillo
Copy link
Contributor

perillo commented May 10, 2021

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

$ go version
go version go1.16.4 linux/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="on"
GOARCH="amd64"
GOBIN="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOENV="/home/manlio/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE="*.local"
GOMODCACHE="/home/manlio/.local/lib/go/pkg/mod"
GONOPROXY=""
GONOSUMDB="*.local"
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3701856854=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.16.4 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.16.4
uname -sr: Linux 5.11.16-arch1-1
/usr/lib/libc.so.6: GNU C Library (GNU libc) release release version 2.33.
gdb --version: GNU gdb (GDB) 10.1

What did you do?

go list -find -json

What did you expect to see?

A missing Package.Deps field, as documented:

The -find flag causes list to identify the named packages but not
resolve their dependencies: the Imports and Deps lists will be empty.

What did you see instead?

"Deps": [
		"runtime"
	]
@jayconrod jayconrod added the NeedsFix The path to resolution is known, but the work has not been done. label May 10, 2021
@jayconrod jayconrod added this to the Backlog milestone May 10, 2021
@perillo
Copy link
Contributor Author

perillo commented May 11, 2021

"Deps": [
		"runtime"
	]

is returned by go1.11 and all later releases. Maybe is the documentation to be wrong?

@perillo
Copy link
Contributor Author

perillo commented May 11, 2021

I was right: it is the documentation to be wrong.

From cmd/go/internal/load/pkg.go Package.load method:

	// The linker loads implicit dependencies.
	if p.Name == "main" && !p.Internal.ForceLibrary {
		for _, dep := range LinkerDeps(p) {
			addImport(dep, false)
		}
	}

@jayconrod
Copy link
Contributor

I think the documentation is correct. When the -find flag is enabled, there's no reason to populate the Deps field by adding these implicit dependencies.

@gopherbot
Copy link

Change https://golang.org/cl/318770 mentions this issue: cmd/go: ignore implicit imports when the -find flag is set

@golang golang locked and limited conversation to collaborators May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants