在Go中编译Google-Fhir Proto文件时出错

时间:2020-05-27 17:00:06

标签: go protocol-buffers hl7-fhir

我无法编译Google的fhir原型

1。我能够生成带有可以解决的警告的notes.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 个答案:

答案 0 :(得分:0)

关于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