💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## 参数为空的grpc请求怎么定义 google protobuf已经提供了空参数 ``` //empty.proto message Empty {} ``` 使用方法,在proto文件中导入`empty.proto`, 定义一个请求参数和返回值为空的函数`emptyfunction`, 函数名字可以自定义。 ``` //server.proto import "google/protobuf/empty.proto"; service pbservice{ rpc emptyfunction(google.protobuf.Empty) return{google.protobuf.Empty} } ``` 以golang语言为例子,在go中对应的函数为: ``` func (s *service) emptyfunction(ctx context.Context, g *google_protobuf.Empty) (*google_protobuf.Empty, error) {} ``` 到此,空请求和空返回的grpc就完成了。