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_test path issue #184

Closed
dimpavloff opened this issue Feb 12, 2017 · 5 comments
Closed

go_test path issue #184

dimpavloff opened this issue Feb 12, 2017 · 5 comments

Comments

@dimpavloff
Copy link
Contributor

I seem unable to build a go_test with a third party dependency in the same BUILD file when the BUILD file is NOT in the repo root. I've created https://github.com/dimpavloff/plz-go-test-bug which shows that.

plz build //:mylib_tests works
plz build //go:mylib_tests (which has identical BUILD and srcs) fails with can't find import: "github.com/stretchr/testify/assert" . If I change //go:mylib_tests's dependency from :testify to //:testifyRoot , it builds fine.

@peterebden
Copy link
Member

This looks like a GOPATH issue. If I add the following to .plzconfig it behaves as expected:

[go]
gopath = $TMP_DIR:$TMP_DIR/go

By default it's set to include third_party/go but not just go. It's not brilliant, I admit, but I'm not sure what's best to do; Go is very awkward about import paths etc. I guess the dream is to make any dependency importable in the "expected way", but it's a little tricky defining exactly what that should be in all cases.

Thoughts?

@dimpavloff
Copy link
Contributor Author

dimpavloff commented Feb 20, 2017

I was hoping this would be a tiny bug somewhere :( I think the third_party/go convention is neat and especially useful for large repos but for small projects it would be nice to have the above option. Would adding the $TMP_DIR/$dirname_of_go_build_target solve it for this use case (i.e. dependencies are sibling targets)?

@peterebden
Copy link
Member

I think that makes sense, yes, adding the current package to GOPATH should be easy & hopefully intuitive.

@natpen
Copy link
Contributor

natpen commented Dec 17, 2017

Is the hard-coding of third_party/go documented anywhere? I can't find mention of it anywhere but in this issue...

For context, I was just messing with a Go project + Please for the first time and was immediately bit by this (I like kebabs more than snakes and set things up using the pattern third-party/go/BUILD instead of third_party/go/BUILD 😋).

@peterebden
Copy link
Member

I guess not well enough then :) The relevant config section is go.gopath, ala plz help gopath; by default it has a few places set to search, although typically any one repo only needs a couple of them.

Setting it to $TMP_DIR:$TMP_DIR/third-party/go should work in your case. I suppose I should add more documentation - that rarely hurts...

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

No branches or pull requests

3 participants