[#51] protogen: Do not panic in StableSize()
All checks were successful
Tests and linters / Lint (pull_request) Successful in 1m56s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m7s
Tests and linters / Tests (1.19) (pull_request) Successful in 2m37s
Tests and linters / Tests with -race (pull_request) Successful in 1m44s

Refs TrueCloudLab/frostfs-node#554 .

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-08-02 10:46:01 +03:00
parent 7a5ee927c8
commit 3072090c77

View file

@ -59,6 +59,7 @@ func emitMessage(g *protogen.GeneratedFile, msg *protogen.Message) {
g.P("//") g.P("//")
g.P("// Structures with the same field values have the same binary size.") g.P("// Structures with the same field values have the same binary size.")
g.P("func (x *", msg.GoIdent.GoName, ") StableSize() (size int) {") g.P("func (x *", msg.GoIdent.GoName, ") StableSize() (size int) {")
g.P("if x == nil { return 0 }")
if len(fs) != 0 { if len(fs) != 0 {
for _, f := range fs { for _, f := range fs {
if f.Desc.IsList() && marshalers[f.Desc.Kind()].RepeatedDouble { if f.Desc.IsList() && marshalers[f.Desc.Kind()].RepeatedDouble {