在Go中编译google-fhir proto文件时出错

问题描述 投票:1回答:1

我无法编译google的fhir原型

1。我能够生成带有可以解决的警告的annotations.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一起使用,并且任何其他语言都需要对文件进行修改。

go protocol-buffers hl7-fhir
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.