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/build: Import on vendor packages behaves differently then import on packages in the GOPATH #22009

Closed
notzippy opened this issue Sep 25, 2017 · 2 comments

Comments

@notzippy
Copy link

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

go 1.8.3, go 1.9

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/notzippy/tmp/deptest/gopath:/home/notzippy/tmp/deptest/project"
GORACE=""
GOROOT="/home/notzippy/.gvm/gos/go1.9"
GOTOOLDIR="/home/notzippy/.gvm/gos/go1.9/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build150164140=/tmp/go-build -gno-record-gcc-switches"
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"

What did you do?

If this file mytest.com/foo/bar/foobar.go is on the GOPATH and build.Import("mytest.com/foo","",build.FindOnly) is called the module package information is returned without an error. But...

If this file is in a vendor folder like /mytest/vendor/mytest.com/foo/bar/foobar.go and build.Import("mytest.com/foo","/mytest",build.FindOnly) is called an error is returned which even indicates that the vendor path was searched but the package was not found, like the following

cannot find package "mytest.com/foo" in any of:                                                                                                                                                                                    
        /mytest/vendor/mytest.com/foo (vendor tree)
...

However with the same setup as above importing the full package name works - like build.Import("mytest.com/foo/bar","/mytest",build.FindOnly) returns without errors.

What did you expect to see?

The package should be located even if it is an empty folder in the vendor folder. This is the way the GOPATH works, so a vendor folder should behave the same way.

What did you see instead?

An error indicating the package could not be found (even though it was in the vendor folder)

@notzippy
Copy link
Author

It appears packages in vendor folder require that go files exist see here. Non vendor files make no such requirements

@notzippy
Copy link
Author

Down the rabbit hole further came across #13832 well that kind of explains things..
Closing

@golang golang locked and limited conversation to collaborators Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants