Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Subpackages do not import properly in a clone outside of GOPATH #134

Closed
encryptio opened this issue Oct 14, 2014 · 3 comments
Closed

Subpackages do not import properly in a clone outside of GOPATH #134

encryptio opened this issue Oct 14, 2014 · 3 comments

Comments

@encryptio
Copy link

I have a program with import path go.company.com/team/prog1 which has "subpackages" inside it, committed to its repo as e.g. go.company.com/team/prog1/helper. I've vendored all the external (other repo) dependencies with godep. Now I'm trying to automate the build and test steps in an external build tool, and prog1's dependencies on its own subpackages cause build failures when cloned outside of a GOPATH:

$ unset GOPATH # only here for clarity, it was actually never set in the first place
$ git clone go.company.com/team/prog1
$ cd prog1
$ godep go test ./...

sourcefile.go:13:2: cannot find package "go.company.com/team/prog1/helper" in any of:
    /usr/lib/golang/src/pkg/go.company.com/team/prog1/helper (from $GOROOT)
    /home/user/prog1/Godeps/_workspace/src/go.company.com/team/prog1/helper (from $GOPATH)
...repeated likewise for all the other subpackage imports...

I've worked around this issue by instead doing this:

$ mkdir -p src/go.company.com/team
$ git clone go.company.com/team/prog1 src/go.company.com/team/prog1
$ export GOPATH=`pwd`
$ cd src/go.company.com/team/prog1
$ godep go test ./...

But this feels like an unneccessary and unintended complication, especially since the exact same script works perfectly fine for a program that does not import any of its own "subpackages".

Before godep was around (near Go 1.0), the build script I wrote for another project to do similar things would copy the repo's contents inside the vendoring workspace, which allowed these "subpackages" to work. That doesn't seem reasonable for godep though, since committing your workspace is the intended use case...

@bohlander
Copy link

I have this same issue

@s3ththompson
Copy link

Me too. I'm trying to get builds working on Travis CI and am running into this issue.

@freeformz
Copy link

godep relies on the go tool and by extension things being compatible with a $GOPATH workspace layout.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants