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;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM