Closed jeberly closed 6 years ago
Thanks for the report! Looking into it today...
I still haven't figured out all the quirks with dep
. I think this issue is due to a pruning issue where unused files are included in the vendor
directory.
@jeberly I finally was able to get time to look into this. I've made some changes to the vendored files and Makefile
. Does make server
work for you to get the server listening on port 8000?
@tonyghita I would like to ask how do you import graphql-go library by dep. When I run dep init on my own repository, it seems that graphql-go cannot detect it. And I manually add it in Gopkg.toml and run dep ensure. It still has nothing changed. But other library works well in dep except graphql-go and go-jwt one. Thanks~
@OscarYuen make sure you run both dep init
and dep ensure
.
I'm not sure if dep
checks your code for usages, but in my experience some dependency managers won't import libraries that are unused. Ensure that you've got a usage of github.com/neelance/graphql-go
in your repository and I'd expect that to work.
Once you've got a usage in your code, you can dep prune
to remove unused files from your vendor
directory.
@tonyghita make server
work for me now. Huge thanks for fixing!
Hi, I'm getting this issue too, am I missing something or is it a bug? Thx
$ make server
▶ Fetching github.com/golang/dep...
go get github.com/golang/dep/cmd/dep
▶ Ensuring vendored dependencies are up-to-date...
dep ensure && dep prune
▶ Embedding schema files into binary...
go generate ./schema
▶ Starting development server...
go run server.go
# graphql-go-example/vendor/github.com/tonyghita/graphql-go-example/schema
vendor/github.com/tonyghita/graphql-go-example/schema/schema.go:21:23: undefined: AssetNames
vendor/github.com/tonyghita/graphql-go-example/schema/schema.go:22:8: undefined: MustAsset
Makefile:18: recipe for target 'server' failed
make: *** [server] Error 2
Hey, that looks like the go generate ./schema
command didn't generate the expected code. What do you get if you only run the go generate ./schema
command?
Hi @tonyghita, thanks for your reply. I have deleted bindata.go and run go generate ./schema
, but getting exactly the same message. I can see that bindata.go was re-generated though.
@tonyghita I think the issue comes from the fact that it is trying to find AssetName and MustAsset from vendor/github.com/tonyghita/graphql-go-example/schema/schema.go
.
But in vendor/github.com/tonyghita/graphql-go-example/schema/schema.go
, the bindata.go was not generated!
So I copied my local MYGOPATH/src/graphql-go-example/schema/bindata.go
to MYGOPATH/src/graphql-go-example/vendor/github.com/tonyghita/graphql-go-example/schema/
and ran server.go
and it worked.
I guess bindata.go was added to .gitignore later on, so the problem only occurs to newcomers...?
What would you advise to avoid this?
Thanks
Ahh, so this project isn't meant to be vendored itself. It's an example application that you'd run on a server.
Thanks again for this example, seems like a well structured example to help get people started.
I am having trouble getting it to build though, perhaps it is my inexperience with
go generate
ordep
, but here is the errors I get even after I attempted to usego generate
.go build
outputThanks for your help.