1

I am unable to compile google's fhir proto for go

1. I was able to generate annotations.pb.go with warnings which can be resolved

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. Unfortunately, I am unable to resolve fixing issues surrounding file not found.

Example the profile_config.proto which contained the following imports

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

Attempting to executed resulted in "not found"

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.

Perhaps these proto files can only be used only with java and any other language would require modification on the files.

Community
  • 1
  • 1
Kam Patel
  • 21
  • 1
  • The path to the proto is dependent on how you run your proto generation. If might require the `,.` in front of it. The proto files are not language dependent, so java should not be the issue – Norbert May 27 '20 at 17:06

1 Answers1

0

Regarding 1., you need to edit every .proto you want to compile and add the go_package option. For instance:

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

Regarding 2., you are setting --proto_path=proto, which leads protoc to search for proto/annotations.proto into the following path:

./proto/proto/annotations.proto

If you don't set this option or set it to --proto_path=. you will be able to compile.

I also suggest taking a look at this pull-request.

volpato
  • 1,262
  • 17
  • 21