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: no Module information in list -e output after any error loading package #44287

Open
myitcv opened this issue Feb 16, 2021 · 6 comments
Open

Comments

@myitcv
Copy link
Member

@myitcv 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.

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Feb 19, 2021

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

@sidntrivedi012 sidntrivedi012 commented Feb 19, 2021

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

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Feb 19, 2021

@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

@supriya-premkumar supriya-premkumar commented Feb 27, 2021

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

@sidntrivedi012
Copy link

@sidntrivedi012 sidntrivedi012 commented Feb 27, 2021

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

@supriya-premkumar supriya-premkumar commented Feb 27, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants