grpc unable to determine Go import path for
前言
在 proto 文件夹下执行如下命令:
$ protoc --go_out=plugins=grpc:. *.proto
报错:无法确定Go导入路径
protoc-gen-go: unable to determine Go import path for "search.proto"
Please specify either:
? a "go_package" option in the .proto source file, or
? a "M" argument on the command line.
See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more informa
tion.
--go_out: protoc-gen-go: Plugin failed with status code 1.
解决方法
在所有的 .proto
文件中指定路径
option go_package ="./pb";
举例:proto文件 新增第三句代码
syntax = "proto3";
package proto;
option go_package ="./proto"; // 指定RPC文件生成路径地址
service SearchService {
rpc Search(SearchRequest) returns (SearchResponse) {}
}
message SearchRequest {
string request = 1;
}
message SearchResponse {
string response = 1;
}