golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.66k stars 1.58k forks source link

Is there a list of all the `--go_opt` and `--go-grpc_opt` options #1431

Open Clement-Jean opened 2 years ago

Clement-Jean commented 2 years ago

i'm working on a tool which provide shell suggestion for protoc and I would like to know if there is a list of all the options for the two flags.

I've use module in the past, such as:

protoc -I. --go_out=. --grpc_out=. --go_opt=module=...  --go-grpc_opt=module=... *.proto

And I cannot seem to find where these options are defined and handled. Could you please guide me ?

geekysaurabh001 commented 2 months ago

2 years and no answer. Excellent 😂

Clement-Jean commented 2 months ago

I forgot to follow up but I found the list of default options for --go_opt. It can be found in the here (the New function in protobuf-go/compiler/protogen/protogen.go).

Here is the list:

As for --go-grpc_opt I'm not sure yet but I'll try to keep this issue updated.

neild commented 2 months ago

https://protobuf.dev/reference/go/go-generated/#invocation documents Go code generator flags.

(I don't think the annotate_code option is documented, but it's also incredibly specialized and you almost certainly don't care about it unless you're trying to write an LSP implementation for protobufs or something.)

The gRPC generator should accept the same flags, in addition to any gRPC-specific ones. I'm not sure where the gRPC generator documentation is.

Clement-Jean commented 2 months ago

Is annotate_code emitting SourceCodeInfo or something like this? I'm actually working on some libraries that are meant to build an LSP, so I'm still interested 😊

neild commented 2 months ago

annotate_code emits a .meta file alongside each .pb.go containing a GeneratedCodeInfo. (See descriptor.proto for the definition.) Where SourceCodeInfo is created by protoc and describes the relationship between a .proto source file and the descriptors in it, GeneratedCodeInfo describes the relationship between the generated code and the .proto source.