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

google.protobuf.Empty import not generating properly #225

Closed
PranavSathy opened this issue Sep 17, 2016 · 3 comments
Closed

google.protobuf.Empty import not generating properly #225

PranavSathy opened this issue Sep 17, 2016 · 3 comments
Labels

Comments

@PranavSathy
Copy link

Hi All, I have a very simple .proto file:

syntax = "proto3";
package service;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";

service TestService {
    rpc PrintAuth(google.protobuf.Empty) returns (google.protobuf.Empty) {
        option (google.api.http) = {
            get: "/client/print"
        };
    }
}

And I am compiling it using the two commands:

protoc -I/usr/local/include -I. \
        -I$GOPATH/src \
        -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
        --go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,Mgoogle/protobuf/empty.proto=github.com/golang/protobuf/ptypes/empty,plugins=grpc:. \
        service/test_service.proto

protoc -I/usr/local/include -I. \
        -I$GOPATH/src \
        -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
        -I$GOPATH/src/github.com/golang/protobuf/ptypes/empty \
        --grpc-gateway_out=logtostderr=true,Mgoogle/protobuf/empty.proto=github.com/golang/protobuf/ptypes/empty:. \
        service/test_service.proto

However, I get this weird issue in my "test_service.pb.gw.go" file, where it imports github.com/golang/protobuf/ptypes/empty but the handler produces the following lines of code:

func request_TestService_PrintAuth_0(ctx context.Context, marshaler runtime.Marshaler, client TestServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
    var protoReq google_protobuf.Empty
    var metadata runtime.ServerMetadata

    msg, err := client.PrintAuth(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
    return msg, metadata, err

}

The issue there is is that google_protobuf.Empty should be empty.Empty. How can I fix this, is there something in particular I am doing wrong?

@yugui yugui added the question label Sep 18, 2016
@yugui
Copy link
Member

yugui commented Sep 18, 2016

Can't reproduce. This is what I got from the steps you had shown.

func request_TestService_PrintAuth_0(ctx context.Context, marshaler runtime.Marshaler, client TestServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
        var protoReq empty.Empty
        var metadata runtime.ServerMetadata

        msg, err := client.PrintAuth(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
        return msg, metadata, err

}

@yugui yugui closed this as completed Sep 18, 2016
@PranavSathy
Copy link
Author

Could it be an issue with my libprotoc (v3.0.0)? I made sure to run go get -u on all the major packages (including github.com/golang/protobuf).

@yugui
Copy link
Member

yugui commented Sep 18, 2016

@PranavSathy I don't think so. But it might be worth to reinstall the latest stable version of protoc just in case.

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

No branches or pull requests

2 participants