Skip to content
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

Package imported but not used #310

Closed
fische opened this issue Feb 5, 2017 · 3 comments
Closed

Package imported but not used #310

fische opened this issue Feb 5, 2017 · 3 comments

Comments

@fische
Copy link
Contributor

fische commented Feb 5, 2017

Hi!
When a service method uses a type T from an imported proto and does not define the option google.api.http to get exposed by the grpc-gateway, protoc-gen-grpc-gateway tries anyway to import the package, where the type T is defined, and therefore I get the following message when I try to compile the gateway:

./main.pb.gw.go:17: imported and not used: "github.com/golang/protobuf/ptypes/empty"

Here's an example of such service:

syntax = "proto3";

import "google/api/annotations.proto";
import "github.com/golang/protobuf/ptypes/empty/empty.proto";

package tester;

service Service {
  rpc MethodExposed (Message) returns (Message) {
    option (google.api.http) = {
      post: "/exposed"
      body: "*"
    };
  }

  rpc MethodImportingEmpty (google.protobuf.Empty) returns (google.protobuf.Empty) {}
}

message Message {
	string value = 1;
}
@tmc
Copy link
Collaborator

tmc commented Feb 6, 2017

@fische thanks for the report -- could you put an example into a failing test case?

@fische
Copy link
Contributor Author

fische commented Feb 7, 2017

The example I've put above is a failing test case.
It tries to import the empty.proto which defines the message type Empty. However the method of Service, that uses this message type, does not define the option google.api.http, so that it does not get exposed by the grpc-gateway. During the code generation of the gateway, protoc-gen-grpc-gateway will add anyway the import of the empty package to the pb.gw.go, even if it is not used.

Edit: I have quickly checked this issue with a mate. It seems that it appeared between 5e41241 and 199c40a.

@tmc
Copy link
Collaborator

tmc commented Feb 17, 2017

@fische I mean can you add a test case that demonstrates the failure (perhaps to #312)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants