我一直在关注 gRPC 教程,这非常好。当我尝试添加 https://github.com/grpc-ecosystem/grpc-gateway 时,问题就开始了到我的项目。我使用他们给你的命令:
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go
我在我的原型(prototype)中导入包:
import "google/api/annotations.proto";
我在上面的行中收到一个错误,说“找不到文件”。
当我在我的项目中复制文件时,它们被发现但是当我运行命令时
protoc -I/usr/local/include -I. \
-I$GOPATH/src \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=plugins=grpc:. \
path/to/your_service.proto
它会提示找不到文件。
有人可以告诉我如何让这个 grpc-gateway 正常工作的正确方法吗?
我目前在使用 GoLand 作为 IDE 的 Windows 上。
最佳答案
如果我正确阅读了此问题,则与您的情况相同。他们说你必须把这些文件放在你的存储库中https://github.com/grpc-ecosystem/grpc-gateway/issues/1065#issuecomment-544241612
关于go - 找不到文件/无法导入包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59234313/