登录
首页 >  Golang >  Go问答

Go 中编译 google-fhir 原型文件的问题

来源:stackoverflow

时间:2024-02-19 15:09:25 311浏览 收藏

知识点掌握了,还需要不断练习才能熟练运用。下面golang学习网给大家带来一个Golang开发实战,手把手教大家学习《Go 中编译 google-fhir 原型文件的问题》,在实现功能的过程中也带大家重新温习相关知识点,温故而知新,回头看看说不定又有不一样的感悟!

问题内容

我无法为 go 编译 google 的 fhir 原型

1。我能够生成带有警告的注释.pb.go,这些警告可以解决

protoc --proto_path=proto  --go_out=.  proto/annotations.proto
2020/05/27 12:42:17 warning: missing 'go_package' option in "annotations.proto",
please specify it with the full go package path as
a future release of protoc-gen-go will require this be specified.
see https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

2。不幸的是,我无法解决与找不到文件相关的问题。

示例 profile_config.proto 包含以下导入

import "proto/annotations.proto";
import "proto/r4/core/codes.proto";
import "proto/r4/core/datatypes.proto";

尝试执行导致“未找到”

protoc --proto_path=proto  --go_out=.  proto/profile_config.proto
proto/annotations.proto: File not found.
proto/r4/core/codes.proto: File not found.
proto/r4/core/datatypes.proto: File not found.

也许这些原始文件只能与 java 一起使用,任何其他语言都需要对文件进行修改。


解决方案


关于1.,您需要编辑每个要编译的.proto并添加go_package选项。例如:

option go_package = "github.com/my-org/my-proj/go/gen/fhir/proto"

关于2.,您设置--proto_path=proto,这会导致protoc在以下路径中搜索proto/annotations.proto

./proto/proto/annotations.proto

如果您不设置此选项或将其设置为 --proto_path=. 您将能够编译。

我还建议您查看 this pull-request

今天带大家了解了的相关知识,希望对你有所帮助;关于Golang的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>