truss icon indicating copy to clipboard operation
truss copied to clipboard

When returned other types, the generated code is incorrect

Open GGXXLL opened this issue 2 years ago • 0 comments

such as google.protobuf.StringValue

proto file:

syntax = "proto3";

package pb;

import "google/api/annotations.proto";
import "google/api/httpbody.proto";
import "google/protobuf/wrappers.proto";

service Hello {
  rpc Helloworld (HelloworldRequest) returns (google.protobuf.StringValue) {
    option (google.api.http) = {
      get: "/hello/"
    };
  }
}

message HelloworldRequest {
  string name = 1;
}

the generated code:

func (s helloService) Helloworld(ctx context.Context, in *pb.HelloworldRequest) (*pb.StringValue, error) {
	var resp pb.StringValue
	return &resp, nil
}

It should be

import types "github.com/gogo/protobuf/types"

...

type HelloServer interface {
	Helloworld(context.Context, *HelloworldRequest) (*types.StringValue, error)
}

GGXXLL avatar Aug 04 '21 08:08 GGXXLL