2

There is gRPC api https://github.com/LTD-Beget/antivirus/tree/master/proto/v1

I want to generate files for GO from this API, but there is no way to add go_package option.

In old version of protoc was cmd option as import_path, and it can can be generated for example by next command

root@d887087e9fa2:/shared/api# protoc -I/usr/local/include -I/shared/api --go_out=import_path=antivirus_proto_v1,M/shared/api/antivirus/proto/v1/antivirus.proto=antivirus_proto_v1,M/shared/api/antivirus/proto/v1/structures.proto=antivirus_proto_v1,plugins=grpc:internal/grpc /shared/api/antivirus/proto/v1/antivirus.proto  /shared/api/antivirus/proto/v1/structures.proto 

But with new version of protoc

protoc-gen-go: no such flag -import_path
--go_out: protoc-gen-go: Plugin failed with status code 1.

follow the guidelines

In order to generate Go code, the Go package's import path must be provided for every .proto file (including those transitively depended upon by the .proto files being generated). There are two ways to specify the Go import path: by declaring it within the .proto file, or by declaring it on the command line when invoking protoc.

but when i declaring it on cmd

root@d887087e9fa2:/shared/api# protoc -I/usr/local/include -I/shared/api --go_out=generated --go-grpc_out=generated --go_opt=M/shared/api/antivirus/proto/v1/antivirus.proto=antivirus/antivirus  --go_opt=M/shared/api/antivirus/proto/v1/structures.proto=antivirus/structures /shared/api/antivirus/proto/v1/antivirus.proto   /shared/api/antivirus/proto/v1/structures.proto 
protoc-gen-go: unable to determine Go import path for "antivirus/proto/v1/structures.proto"

Please specify either:
        • a "go_package" option in the .proto source file, or
        • a "M" argument on the command line.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

what am i missing?

DeYuro
  • 65
  • 5

0 Answers0