环境:

  • kitex --version v0.4.4
  • protoc --version libprotoc 3.21.12

proto格式配置文件:

hello.proto

syntax = "proto3";

option go_package = "hello2";

package hello2;


// 问题 这里的谷歌自带格式 kitex不兼容
import "google/protobuf/timestamp.proto";

// 请求入参
message Request {
  string name = 1;
  int32 id = 2;
  google.protobuf.Timestamp update_time = 3;
  repeated ReqBody req_body = 4; // repeated 是go中的slice
}
message ReqBody {
  string number = 1;
  int32 id =2;
}

message Response {
  int64 code = 1;
  string msg = 2;
}

service Hello2Service {
  rpc ClientSideStreaming(stream Request) returns (Response) {} // 客户端侧 streaming
  rpc ServerSideStreaming(Request) returns (stream Response) {} // 服务端侧 streaming
  rpc BidiSideStreaming(stream Request) returns (stream Response) {} // 双向流
}

kitex命令行生成文件:

kitex  -module "kitex-ex" -type protobuf -service hello2service -I idl/ idl/hello2.proto

执行后提醒:

 [WARN] "google/protobuf/timestamp.proto" is skipped because its import path "google.golang.org/protobuf/types/known/timestamppb" is not located in ./kitex_gen. Change the go_package option or use '--protobuf Mgoogle/protobuf/timestamp.proto=A-Import-Path-In-kitex_gen' to override it if you want this file to be generated under kitex_gen.

按照提示加入 --protobuf Mgoogle/protobuf/timestamp.proto=A-Import-Path-In-kitex_gen 或者将include包放到 /usr/local/include 包 或者$GOPATH/bin/include都不行。

具体提示异常:

 有使用kitex的大佬可以帮忙指导一下谢谢;