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

go/importer: importer.For("source") fails to load packages from testdata paths #24392

Closed
eliasnaur opened this issue Mar 14, 2018 · 5 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@eliasnaur
Copy link
Contributor

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

go version devel +29fcd57a9f Sun Mar 4 22:53:50 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/elias/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/elias/dev/go"
GORACE=""
GOROOT="/home/elias/dev/go-tip"
GOTMPDIR=""
GOTOOLDIR="/home/elias/dev/go-tip/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build722960365=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Ran

$ GOPATH=`pwd` go run srcimport.go

in the srcimporter directory from the attached srcimporterbug.zip

What did you expect to see?

No errors.

What did you see instead?

2018/03/14 18:54:52 got "." want "example.com/testdata/testpkg"

Somehow, the srcimporter is confused by the presence of "testdata" in the import path.

The importer.Default() importer works as expected, after running

$ GOPATH=`pwd` go install example.com/testdata/testpkg

I think this is related to #23092 since its proposed CL 83415 also fixes this problem.

@josharian
Copy link
Contributor

@griesemer

@griesemer griesemer added this to the Go1.11 milestone Mar 14, 2018
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 14, 2018
@gopherbot
Copy link

Change https://golang.org/cl/83415 mentions this issue: go/internal/srcimporter: fix misuse of build.Import and build.ImportDir

@eliasnaur
Copy link
Contributor Author

eliasnaur commented Mar 18, 2018

Please consider the fix for a 1.10 point release. Between this issue and #23092, I can't use source imports from gomobile before the importer is fixed at least two releases back. Without a 1.10.1 release, that means from 1.12, almost a year from now.
Gomobile could vendor the fixed importer, but then there is the risk of version skew, as described in https://golang.org/cl/16911 where that was one of the reasons gomobile switched away from another source importer (x/tools/go/loader).

@griesemer
Copy link
Contributor

@eliasnaur Filed #24452 .

@gopherbot
Copy link

Change https://golang.org/cl/102789 mentions this issue: [release-branch.go1.10] go/internal/srcimporter: simplify and fix package file lookup

gopherbot pushed a commit that referenced this issue Mar 29, 2018
…kage file lookup

The old code was a blend of (copied) code that existed before go/build,
and incorrect adjustments made when go/build was introduced. This change
leaves package path determination entirely to go/build and in the process
fixes issues with relative import paths.

Fixes #23092
Fixes #24392

Change-Id: I9e900538b365398751bace56964495c5440ac4ae
Reviewed-on: https://go-review.googlesource.com/83415
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-on: https://go-review.googlesource.com/102789
Run-TryBot: Andrew Bonventre <andybons@golang.org>
@golang golang locked and limited conversation to collaborators Mar 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants