protobuf
protobuf copied to clipboard
protoc-gen-go: add doc comment to String method to explain its output isn't stable
Is your feature request related to a problem? Please describe.
I wrote code as part of an Example style test that used the generated String() method, forgetting about issue #1121. While it shouldn't have taken me long to figure out this, it did! (I was focused on trying to understand the code that caused instability, and didn't read the doc comment on the Format() method, until much too late.)
Describe the solution you'd like
It would help if a doc comment had surfaced this from the generated messages' String() methods.
// String returns the message as a string.
// This method is only intended for human consumption and ignores errors.
// Do not depend on the output being stable. It may change over time across
// different versions of the program.
I guess the doc comment could be written more briefly if the number of comment lines is a concern.
In addition to concerns about duplication of this same messaging on every generated message, I suspect that most calls to the String method do not happen directly, but indirectly through fmt.Printf and another functionality that understand the fmt.Stringer interface.