Skip to content

cmd/go: no Module information in list -e output after any error loading package #44287

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

Closed
myitcv opened this issue Feb 16, 2021 · 7 comments
Closed
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Feb 16, 2021

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

$ go version
go version devel +0cb3415154 Tue Feb 16 02:07:02 2021 +0000 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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/myitcv/gostuff/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel +0cb3415154 Tue Feb 16 02:07:02 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/tmp.MFFZzggPNu/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build741706514=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go list -e -f {{.Module}}

-- blah.go --
package blah

import _ "embed"

//go:embed README.md
var readme string
-- go.mod --
module mod.com

go 1.16

What did you expect to see?

mod.com

What did you see instead?

<nil>

This has implications for users of go list, i.e. go/packages.

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Feb 16, 2021
@jayconrod jayconrod added this to the Go1.17 milestone Feb 19, 2021
@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. help wanted and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 19, 2021
@jayconrod
Copy link
Contributor

In cmd/go/internal/load.Package.load, it looks like we don't populate the Module field if there was any error loading the package. For example, if a blah.c file is present but the package doesn't use cgo or swig, the Error field is populated but the Module field is not.

I don't think anything prevents us from populated the Module field here.

@jayconrod jayconrod changed the title cmd/go: unsatisfied go:embed directive causes no Module information in list -e output cmd/go: no Module information in list -e output after any error loading package Feb 19, 2021
@sidntrivedi012
Copy link

Hey @jayconrod , I would like to help out to fix this issue. How should I proceed? Thanks :)

@jayconrod
Copy link
Contributor

@sidntrivedi012 Your help is most welcome.

I think this can be fixed in pkg.go by moving this block up to right after we push the import path on the stack.

Please make sure to add a regression test in src/cmd/go/testdata/script. There's a README there that explains the format.

@supriya-premkumar
Copy link

I can take this one up if this in the backlog. @jayconrod Please feel free to assign this one to me. 🙏🏽

@sidntrivedi012
Copy link

Hey @supriya-premkumar , I got somewhat stuck in the weekdays so couldn't get the bandwidth to work on it.

I am planning to write a patch for it in this weekend. Will surely comment here to assign it to you if I fail to triage it.

Thanks 😃

@supriya-premkumar
Copy link

Hey @supriya-premkumar , I got somewhat stuck in the weekdays so couldn't get the bandwidth to work on it.

I am planning to write a patch for it in this weekend. Will surely comment here to assign it to you if I fail to triage it.

Thanks 😃

No worries at all. Go for it!

unbyte added a commit to unbyte/go that referenced this issue Apr 26, 2021
The existing implementation ignores module info if there is any error loading the package.

Fixes golang#44287
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/313549 mentions this issue: cmd/go: populate module info even certain error occurs in go list

unbyte added a commit to unbyte/go that referenced this issue Apr 28, 2021
The existing implementation ignores module info if there is any error loading the package.

Fixes golang#44287
unbyte added a commit to unbyte/go that referenced this issue Apr 28, 2021
The existing implementation ignores module info if there is any error loading the package.

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

Successfully merging a pull request may close this issue.

5 participants