-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Invalid import during code generation #337
Comments
Okay, I realized I was using the deprecated way of googleapis import instead of |
@sagikazarmark can you clarify further here for anyone that might run into the same thing? |
I added the "old" googleapis import path from this repo to the protoc command: Adding the official googleapis repo as a dependency solved the problem. See the solution here. |
I would like to use gRPC Gateway, because it looks incredibly awesome, but I encountered the following problem and I haven't been able to solve it so far:
When trying to use Google's http annotations, the generated pb.go file looks a bit strange. It includes the following:
import _ "google/api"
I have to admit that I don't use protoc as it is described in the README, but I think it should work this way too. Furthermore, I've tried every combination of import paths, none of them worked.
I use multiple paths in my
GOPATH
variable: there is one for package installations (the first) and the other where my code lives. Something like this:$HOME/.go:$HOME/Projects/go
Also, my
protoc
binary is copied to my own binary prefix. I know that it might not found certain files that way, but I provide an import path for the protobuf protos.I use Glide for vendoring.
So my actual command is:
protoc -I ${PROTO_PATH} -I vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I vendor/github.com/google/protobuf/src ${PROTO_PATH}/iam/user/v1alpha1/login.proto --go_out=plugins=grpc:apis
As you can see, I add googleapis and protobuf as import path (besides the one where my actual proto file lives).
My proto looks like this:
I believe it should work this way, but it generates a file with the above import. Looking at the examples in this repository I see imports like this:
import _ "google.golang.org/genproto/googleapis/api/annotations"
I'm a little bit confused, because I don't understand how the go protoc plugin guesses where it should look for the generated file of a proto.
Any help would be appreciated, thank you very much in advance.
The text was updated successfully, but these errors were encountered: