I'm trying to create Go gRPC-client code with this proto from the Nighthawk project and I'm getting this error:
user@computer:~/Code/nighthawk$ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative api/client/output.proto
envoy/config/core/v3/base.proto: File not found.
envoy/config/metrics/v3/stats.proto: File not found.
envoy/extensions/transport_sockets/tls/v3/cert.proto: File not found.
envoy/config/core/v3/extension.proto: File not found.
validate/validate.proto: File not found.
api/client/options.proto: Import "envoy/config/core/v3/base.proto" was not found or had errors.
api/client/options.proto: Import "envoy/config/metrics/v3/stats.proto" was not found or had errors.
api/client/options.proto: Import "envoy/extensions/transport_sockets/tls/v3/cert.proto" was not found or had errors.
api/client/options.proto: Import "envoy/config/core/v3/extension.proto" was not found or had errors.
api/client/options.proto: Import "validate/validate.proto" was not found or had errors.
api/client/options.proto:16:3: "envoy.config.core.v3.RequestMethod" is not defined.
api/client/options.proto:17:12: "envoy.config.core.v3.HeaderValueOption" is not defined.
api/client/options.proto:186:5: "envoy.config.core.v3.TypedExtensionConfig" is not defined.
api/client/options.proto:190:3: "envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext" is not defined.
api/client/options.proto:253:3: "envoy.config.core.v3.TransportSocket" is not defined.
api/client/options.proto:259:12: "envoy.config.metrics.v3.StatsSink" is not defined.
api/client/output.proto: Import "envoy/config/core/v3/base.proto" was not found or had errors.
api/client/output.proto: Import "api/client/options.proto" was not found or had errors.
api/client/output.proto:57:3: "nighthawk.client.CommandLineOptions" is not defined.
api/client/output.proto:59:3: "envoy.config.core.v3.BuildVersion" is not defined.
I see that these protos are defined in Envoy's repository here.
How do I import these so that I can generate the client code?
What is the command for this? Am I missing anything?
Generally you should not be building your own .pb.go
files from other people's .proto
files. Go will panic if multiple definitions of the same proto package are found in a single binary, so every .proto
file published should ideally also provide .pb.go
files in a central location. If that isn't the case for nighthawk, then you can still build that yourself. You'll need to download the Envoy dependencies and reference them via the -I
parameter.