docs: guidelines for proto message's String() method (#13364)

This commit is contained in:
likhita-809 2022-09-23 00:18:07 +05:30 committed by GitHub
parent 89aa914bed
commit 8dd708d9cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -280,6 +280,19 @@ type UnpackInterfacesMessage interface {
}
```
### Custom Stringer
Using `option (gogoproto.goproto_stringer) = false;` in a proto message definition leads to unexpected behaviour, like returning wrong output or having missing fields in the output.
For that reason a proto Message's `String()` must not be customized, and the `goproto_stringer` option must be avoided.
A correct YAML output can be obtained through ProtoJSON, using the `JSONToYAML` function:
+++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/codec/yaml.go#L8-L20
For example:
+++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/auth/types/account.go#L139-L151
## Next {hide}
Learn about [gRPC, REST and other endpoints](./grpc_rest.md) {hide}