ffjson
ffjson copied to clipboard
Could not find source directory
$ go run test.go
works just fine but trying ffjson
I get
$ type ffjson
ffjson is hashed (/Users/tcurdt/Projects/json/.godeps/bin/ffjson)
$ ls -la
total 24
drwxr-xr-x 6 tcurdt staff 204 Mar 11 14:15 .
drwx------@ 13 tcurdt staff 442 Mar 11 16:41 ..
drwxr-xr-x 5 tcurdt staff 170 Mar 11 14:04 .godeps
-rw-r--r--@ 1 tcurdt staff 25 Mar 11 14:05 Godeps
-rw-r--r--@ 1 tcurdt staff 1450 Mar 11 14:57 test.go
-rw-r--r--@ 1 tcurdt staff 1269 Mar 11 14:53 test.json
$ ffjson test.go
Error: error=Could not find source directory: GOPATH=["/Users/tcurdt/Projects/json/.godeps" "/Users/tcurdt/Projects/json"] REL="/Users/tcurdt/Projects/json" path="":
$ echo $GOPATH
/Users/tcurdt/Projects/json/.godeps:/Users/tcurdt/Projects/json
hmm. i guess we can should try to match argv paths to any matching $GOPATH, rather than just chopping the first $GOPATH entry.
@tcurdt: if you change your $GOPATH to /Users/tcurdt/Projects/json:/Users/tcurdt/Projects/json/.godeps
I suspect it will work.
Hm - doesn't :-/
ls `echo $GOPATH | cut -d ':' -f 1 | sed -e 's#$#/test.go#'`
/Users/tcurdt/Projects/customer/json/test.go
$ ffjson test.go
Error: error=Could not find source directory: GOPATH=["/Users/tcurdt/Projects/json" "/Users/tcurdt/Projects/json/.godeps"] REL="/Users/tcurdt/Projects/json" path="":
When I only have the local dir in the GOPATH
I get
$ ffjson test.go
Error: error=Could not find source directory: GOPATH=["/Users/tcurdt/Projects/json"] REL="/Users/tcurdt/Projects/json" path="":
Also seems like multiple GOPATH
entries are handled.
https://github.com/pquerna/ffjson/blob/master/generator/inceptionmain.go#L116
After looking at the code moving it to src/test/test.go
worked :)
hmm. where did you 'learn' to $GOPATH? the src/
org is what golang docs officially do now, go get
implements, etc
Sure - but it's just simple script.
Those usually work fine by just using go run
and don't required that structure.
It's up to you if you want to keep this open or close. I think it would be nice to catch this and at least give better error message though.
Thx, Paul :)
Does multivalue gopath need fixing?
It seems like it should either be fixed, or documented.
@klauspost well, it does support multivalues - but seems it does not support locations other than src
properly.
I would call it a bug - but it's easy to work around.
I just experienced this. I would call it a bug too. go build/run work in my source directory: this should do the same.
Using tools like gb
makes you use a different (and better IMO) approach of organizing your code and vendor code.
This doesn't work for me as well:
$ ffjson src/github.com/pires/server/api.go
Error: error=Could not find source directory: GOPATH=["/Users/pires/Work/Projects/go"] REL="/Users/pires/Work/server/src/github.com/pires/server" path="":
$ ffjson api.go
Error: error=Could not find source directory: GOPATH=["/Users/pires/Work/Projects/go"] REL="/Users/pires/Work/server/src/github.com/pires/server" path="":