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: ignore packages with all files skipped due to 'package documentation' when matching wildcards #38678

Open
slon opened this issue Apr 26, 2020 · 10 comments
Milestone

Comments

@slon
Copy link
Contributor

@slon slon commented Apr 26, 2020

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

$ go version
go version go1.14.2 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/prime/.cache/go-build"
GOENV="/home/prime/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/prime/Code/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/docerror/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-build420640243=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I created go module with a single .go file in it.

prime@bee /t/docerror> cat doc.go
package documentation
prime@bee /t/docerror> cat go.mod
module github.com/slon/docerror

go 1.14
prime@bee /t/docerror> go list github.com/slon/docerror/...
can't load package: package github.com/slon/docerror: build constraints exclude all Go files in /tmp/docerror

What did you expect to see?

go list command finishing without errors

What did you see instead?

go list fails with strange error.

@andybons andybons changed the title go list fails on package containing single file with magic "documentation" package name cmd/go: go list fails on package containing single file with magic "documentation" package name Apr 27, 2020
@andybons andybons added this to the Unplanned milestone Apr 27, 2020
@andybons
Copy link
Member

@andybons andybons commented Apr 27, 2020

@bcmills
Copy link
Member

@bcmills bcmills commented Apr 27, 2020

That comes from the go/build package, here:

go/src/go/build/build.go

Lines 864 to 867 in 08bf64a

if pkg == "documentation" {
p.IgnoredGoFiles = append(p.IgnoredGoFiles, name)
continue
}

@bcmills
Copy link
Member

@bcmills bcmills commented Apr 27, 2020

This behavior has been present since at least CL 4433047, 9 years ago.

We presumably cannot change it at this point, since un-ignoring these files could break existing packages. We would need to gate the change on the go version specified in the go.mod file, and that degree of complexity does not seem worthwhile to me just to open up one package name — but if you feel otherwise, please feel free to open a separate proposal.

I think the most we can do without an invasive breaking change is to document the current behavior.

@bcmills bcmills changed the title cmd/go: go list fails on package containing single file with magic "documentation" package name cmd/go: document that .go files with 'package documentation' are implicitly ignored Apr 27, 2020
@bcmills bcmills added the NeedsFix label Apr 27, 2020
@bcmills bcmills modified the milestones: Unplanned, Backlog Apr 27, 2020
@slon
Copy link
Contributor Author

@slon slon commented Apr 28, 2020

I'm not suggesting that these go files should be included in the build.

The problem is that go list finishes with exit code 1. I expect, that go list should handle such edge-case internally and ignore this package completely.

@bcmills
Copy link
Member

@bcmills bcmills commented Apr 28, 2020

Ahh, I see what you mean. Thanks for the clarification.

@bcmills bcmills changed the title cmd/go: document that .go files with 'package documentation' are implicitly ignored cmd/go: ignore packages with all files skipped due to 'package documentation' when matching wildcards Apr 28, 2020
@bcmills bcmills added help wanted and removed Documentation labels Apr 28, 2020
@samarthtambad
Copy link

@samarthtambad samarthtambad commented May 26, 2020

Hi, may I can take this up?

@sibis
Copy link

@sibis sibis commented Sep 10, 2020

@bcmills First time contributor here. Interested in contributing to this issue. Please throw some lights on starting with.

Thanks

@bcmills
Copy link
Member

@bcmills bcmills commented Sep 14, 2020

@samarthtambad, @sibis: I'm not sure that this would be a good first contribution, unfortunately. The interactions between go/build and the cmd/go package loader are somewhat subtle.

@bcmills bcmills removed the help wanted label Sep 14, 2020
@slon

This comment was marked as off-topic.

@bcmills

This comment was marked as off-topic.

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
6 participants
You can’t perform that action at this time.