grpc-go icon indicating copy to clipboard operation
grpc-go copied to clipboard

protoc-gen-go-grpc: Header text from .proto file isn't brought over to the *_grpc.pb.go files

Open RedHawker opened this issue 3 years ago • 6 comments

The base protoc-gen-go plugin copies any header comment(s) from the .proto file, but protoc-gen-go-grpc does not.

Use case(s) - what problem will this feature solve?

We use file headers for copyright/legal information; our source files (including generated ones) need to have our header comment block in them.

Without protoc-gen-go-grpc doing it like protoc-gen-go does, we'll have to add an additional step to get that comment added.

Proposed Solution

Mirror what protoc-gen-go does, and copy any header comments (anything before the syntax = ....; line?)

Alternatives Considered

Workaround in our generation process, to manually add the comment.

Additional Context

Can add if needed, but the issue seems straightforward to me.

RedHawker avatar Jul 21 '22 17:07 RedHawker

We would be happy to review if you can send a PR for this. Thanks.

easwars avatar Jul 26 '22 21:07 easwars

I'm not sure what you mean. I don't know how protoc-gen-go does it, I just know this plugin doesn't.

I don't think it's necessarily a bug, just a missing feature; I assumed the maintainers of this plugin would know best on how to go about getting it added.

If you're saying you're not going to spend any dev effort on doing it, then sure, I'll learn the code and figure out how it works, since it would be a useful feature to have.

RedHawker avatar Jul 26 '22 21:07 RedHawker

Yes, I agree this is a good to have feature. But we don't have the dev cycles to get to this any time soon. So, if you would like to contribute a change, we will be more than happy to review it. Thanks.

easwars avatar Jul 26 '22 21:07 easwars

I have working code, but the example I got it from uses an internal field. Maybe I'll make a PR and you all can advise to a better solution?

RedHawker avatar Jul 26 '22 22:07 RedHawker

Sure, please send a PR and we will review it. Thanks.

easwars avatar Jul 26 '22 22:07 easwars

Created the PR above. You can see from the "Testing vet-proto" stage the header comment in the _grpc.pb.go files.

RedHawker avatar Jul 27 '22 15:07 RedHawker

The PR has been merged in #5540, closing this issue.

RedHawker avatar Sep 06 '22 21:09 RedHawker