clipperhouse / gen

Type-driven code generation for Go
http://clipperhouse.com/gen/overview/
Other
1.43k stars 90 forks source link

error message (import) #73

Closed pierrre closed 9 years ago

pierrre commented 9 years ago

In my package github.com/pierrre/geohash I try to create a slice of Point (https://github.com/pierrre/geohash/blob/master/geohash.go#L113-L116).

But gen returns an error:

➜  geohash git:(master) ✗ gen
geohash_benchmark_test.go:6:18: could not import github.com/Codefor/geohash (can't find import: github.com/Codefor/geohash)
exit status 1

or

➜  geohash git:(master) ✗ gen
cstest_test.go:6:2: could not import github.com/pierrre/cstest (can't find import: github.com/pierrre/cstest)
exit status 1
rkoster commented 9 years ago

@pierrre does go install work for you? Because I also encountered this issue and it was the result of just having build errors in my code. After fixing those error the import message went away.

pierrre commented 9 years ago

https://travis-ci.org/pierrre/geohash

pierrre commented 9 years ago

I understand my problem: I need to manually install all my dependencies in $GOPATH/pkg. All my dependencies are already in $GOPATH/src, but I must run go install xxxxx.

➜  geohash git:(master) gen
geohash_benchmark_test.go:6:18: could not import github.com/Codefor/geohash (can't find import: github.com/Codefor/geohash)
➜  geohash git:(master) go install -v github.com/Codefor/geohash
github.com/Codefor/geohash
➜  geohash git:(master) gen                                     
geohash_benchmark_test.go:7:24: could not import github.com/TomiHiltunen/geohash-golang (can't find import: github.com/TomiHiltunen/geohash-golang)
➜  geohash git:(master) go install -v github.com/TomiHiltunen/geohash-golang
github.com/TomiHiltunen/geohash-golang
➜  geohash git:(master) gen                                                 
geohash_benchmark_test.go:8:17: could not import github.com/broady/gogeohash (can't find import: github.com/broady/gogeohash)
➜  geohash git:(master) go install -v github.com/broady/gogeohash           
github.com/broady/gogeohash
➜  geohash git:(master) gen                                      
cstest_test.go:6:2: could not import github.com/pierrre/cstest (can't find import: github.com/pierrre/cstest)
➜  geohash git:(master) go install -v github.com/pierrre/cstest  
github.com/pierrre/cstest
➜  geohash git:(master) gen                                    
geohash_benchmark_test.go:9:28: could not import github.com/the42/cartconvert/cartconvert (can't find import: github.com/the42/cartconvert/cartconvert)
➜  geohash git:(master) go install -v github.com/the42/cartconvert/cartconvert
github.com/the42/cartconvert/cartconvert
➜  geohash git:(master) gen                                                   
No types marked with +gen were found. See http://clipperhouse.github.io/gen to get started, or type gen help.
clipperhouse commented 9 years ago

Consider this resolved, then?

pierrre commented 9 years ago

Not really, why should I install these packages? (in $GOPATH/pkg) Other commands like go test, gofmt, golint or goconvey automatically install these packages.

clipperhouse commented 9 years ago

I don’t think this is a gen problem. The package on which you call gen needs to be correct and buildable – try go build first. Once the package is correct, gen can do its thing.

pierrre commented 9 years ago

go build is OK, but gen returns an error:

➜  geohash git:(master) rm -r $GOPATH/pkg
➜  geohash git:(master) go build -v
github.com/pierrre/geohash
➜  geohash git:(master) go test
PASS
ok      github.com/pierrre/geohash  0.120s
➜  geohash git:(master) gen
geohash_benchmark_test.go:6:18: could not import github.com/Codefor/geohash (can't find import: github.com/Codefor/geohash)
➜  geohash git:(master)

Try to remove your $GOPATH/pkg directory. gen doesn't work for me if dependencies are not explicitly installed in $GOPATH/pkg.