字节开源kitex框架:protobuf编码生成序列化代码,不能识别google基础类型google/protobuf/timestamp.proto

乏善可陈 2023-01-12 11:25:06

环境:

  • 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的大佬可以帮忙指导一下谢谢;

 

...全文
357 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,190

社区成员

发帖
与我相关
我的任务
社区描述
go语言学习与交流版
社区管理员
  • go语言社区
  • Freeman Z
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧