// 添加部分 import "google/api/annotations.proto";
来源:14-3 基本知识科普 - 构建grpc-gateway 测试服务端让服务器支持http

慕工程7462913
2020-11-10
老师,这部分代码报错呀,你演示的时候你的编译器也报错呀
// 添加部分
import "google/api/annotations.proto";
google/api/annotations.proto: File not found.
echo-gateway.proto:6:1: Import “google/api/annotations.proto” was not found or had errors.
2回答
-
牛儿吃草
2020-11-14
需要确认一点,go mod默认在命令行下有没有开启,如果没开启就默认走 $GOPATH,否则就走 pkg/mod
00 -
慕工程7462913
提问者
2020-11-10
protoc -I/usr/local/include -I. -I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.0.1/third_party/googleapis --go_out=proto echo-gateway.proto
protoc -I/usr/local/include -I. -I$GOPATH/pkg/mod/github.com/grpc-ecosystem/grpc-gateway/v2@v2.0.1/third_party/googleapis --go-grpc_out=proto echo-gateway.proto
这样可以,不能使用$GOPATH/src,也不能指定plugins,不然报错
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC
00
相似问题