ffjson icon indicating copy to clipboard operation
ffjson copied to clipboard

Could not find source directory

Open tcurdt opened this issue 9 years ago • 11 comments

$ 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

tcurdt avatar Mar 11 '15 16:03 tcurdt

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.

pquerna avatar Mar 11 '15 16:03 pquerna

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

tcurdt avatar Mar 11 '15 16:03 tcurdt

After looking at the code moving it to src/test/test.go worked :)

tcurdt avatar Mar 11 '15 16:03 tcurdt

hmm. where did you 'learn' to $GOPATH? the src/ org is what golang docs officially do now, go get implements, etc

pquerna avatar Mar 11 '15 16:03 pquerna

Sure - but it's just simple script. Those usually work fine by just using go run and don't required that structure.

tcurdt avatar Mar 11 '15 16:03 tcurdt

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 :)

tcurdt avatar Mar 11 '15 17:03 tcurdt

Does multivalue gopath need fixing?

It seems like it should either be fixed, or documented.

klauspost avatar Mar 13 '15 08:03 klauspost

@klauspost well, it does support multivalues - but seems it does not support locations other than src properly.

tcurdt avatar Mar 13 '15 08:03 tcurdt

I would call it a bug - but it's easy to work around.

tcurdt avatar Mar 13 '15 09:03 tcurdt

I just experienced this. I would call it a bug too. go build/run work in my source directory: this should do the same.

vessenes avatar May 14 '15 17:05 vessenes

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="":

pires avatar Aug 11 '15 11:08 pires