Closed yangjuncode closed 1 month ago
I am not understanding what your issue here is. I have downloaded your test.tar.gz
and compiled with protoc-gen-go@v1.34.2
and the only thing that changed in the comment is that protoc
is now reflects the version of protoc
that I have installed on my system.
There is no reason why the original comment should be kept, if the .pb.go
file is generated with a different version of protoc
or protoc-gen-go
. That’s literally the purpose of the comments: to document the versions it was generated through.
I am not understanding what your issue here is. I have downloaded your
test.tar.gz
and compiled withprotoc-gen-go@v1.34.2
and the only thing that changed in the comment is thatprotoc
is now reflects the version ofprotoc
that I have installed on my system.There is no reason why the original comment should be kept, if the
.pb.go
file is generated with a different version ofprotoc
orprotoc-gen-go
. That’s literally the purpose of the comments: to document the versions it was generated through.
the problem is show in screenshot, in proto there is ''(two char), in generated pb.go file, it's ”(one char).
We’re calling into go/doc/comment/Parser
here: https://github.com/golang/go/blob/master/src/go/printer/comment.go#L61-L63
This converts double backtick to “
and double apostrophe to ”
here: https://github.com/golang/go/blob/master/src/go/doc/comment/parse.go#L942-L960
This is apparently a feature, not a bug?
P.S.: minimal repro on playground: https://go.dev/play/p/hR2WLK26fIo
oops, well it's a feature of go doc, but it's a surprise for proto user
What version of protobuf and what language are you using? // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 // protoc v5.28.1 // source: test.proto
What did you do? protoc --go_out=. test.proto
What did you expect to see? keep the original comment in generated go file
What did you see instead? the ''(two char) in proto file become ”(one char) in generated go file
test.tar.gz