【发布时间】:2020-10-04 14:58:40
【问题描述】:
我最熟悉 Python 和 bazel 构建环境。我正在尝试在 Go 中重写一部分代码,并且我正在努力让 proto 导入正确对齐。
在 github.com/djhedges/exit_speed/gps.proto 我已经设置了 go_package 像这样
option go_package = "github.com/djhedges/exit_speed/gps_go_proto";
我添加了一个反射器.proto,它导入 gps.proto 并重用其中定义的一些消息。
import "gps.proto";
我用
编译gps.proto
protoc -I ./ --go_out=./ --go_opt=paths=source_relative --python_out ./ gps.proto
并编译reflector.proto
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1 python3 -m grpc_tools.protoc -I ./ --go_out=./ --go_opt=paths=source_relative --python_out ./ --grpc_python_out ./ reflector.proto
最后在 exit_speed/reflector.go 我尝试导入 gps_go_proto
import gpspb "github.com/djhedges/exit_speed/gps_go_proto"
哪些错误
go: finding github.com/djhedges/exit_speed/gps_go_proto latest
reflector.go:21:2: unknown import path "github.com/djhedges/exit_speed/gps_go_proto": cannot find module providing package github.com/djhedges/exit_speed/gps_go_proto
如果可能,我更愿意将 gps.proto 保留在根目录中,因为我已将 protos 登录到数据文件中,并且我相信移动它会破坏 proto 解析。我想我可以写一个迁移脚本。
我也对如何使用不同的 go 包和导入设置多个原型感到困惑。 go 包必须有一个专用文件夹吗?
【问题讨论】:
标签: go protocol-buffers