[#51] protogen: Do not panic in StableSize()
All checks were successful
All checks were successful
Refs TrueCloudLab/frostfs-node#554 . Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
7a5ee927c8
commit
3072090c77
1 changed files with 1 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue