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: import of vendored package error "cannot find package" from testdata package #50143

Open
prattmic opened this issue Dec 13, 2021 · 3 comments

Comments

@prattmic
Copy link
Member

@prattmic prattmic commented Dec 13, 2021

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

$ go version
go version devel go1.18-f6d4b9ad5c Mon Dec 13 16:39:15 2021 -0500 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="/usr/local/google/home/mpratt/.cache/go-build"
GOENV="/usr/local/google/home/mpratt/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/usr/local/google/home/mpratt/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/google/home/mpratt/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/google/home/mpratt/src/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/mpratt/src/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-f6d4b9ad5c Mon Dec 13 16:39:15 2021 -0500"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/usr/local/google/home/mpratt/src/go/src/go.mod"
GOWORK=""
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-build1377042719=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. Checkout https://golang.org/cl/371298
  2. Build: ./bin/go build cmd/testdata/foo

What did you expect to see?

Successful build

What did you see instead?

cmd/testdata/foo/main.go:4:2: cannot find package

Note that the binary in cmd/foo builds just fine. The only difference is that the former is in a testdata/ directory. golang.org/x/sys/unix is vendored in cmd/vendor/....

cc @bcmills

@bcmills
Copy link
Member

@bcmills bcmills commented Dec 13, 2021

Funky. I modified cmd/go/internal/modload.(*loader).stdVendor to log the return vendorPath exits, and it is resolving these imports to the correct paths. I'm not sure where they're being lost. 🤔

@bcmills bcmills added this to the Backlog milestone Dec 13, 2021
@bcmills
Copy link
Member

@bcmills bcmills commented Dec 13, 2021

Oddly, though, the module loader sees the package as inStd but go list -e -f {{.Standard}} reports false.

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 13, 2021

Change https://golang.org/cl/371298 mentions this issue: DO NOT SUBMIT: testdata vendoring bug

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
3 participants