preface
Execute the following command in the proto folder:
$ protoc --go_out=plugins=grpc:. *.proto
Error: unable to determine the go import path
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.
Solution:
Specify the path in all .Proto
files
option go_package ="./pb";
Example: the third sentence code is added to the proto file
syntax = "proto3";
package proto;
option go_package ="./proto"; // Specify the RPC file generation path address
service SearchService {
rpc Search(SearchRequest) returns (SearchResponse) {}
}
message SearchRequest {
string request = 1;
}
message SearchResponse {
string response = 1;
}