From 78cb5588b15f20cb8038c40da2b7b42051b99b9a Mon Sep 17 00:00:00 2001 From: Pat Moroney Date: Fri, 12 Jan 2018 11:12:15 -0700 Subject: [PATCH] make nilString constant --- helpers/helpers.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/helpers/helpers.go b/helpers/helpers.go index e21577a..5e8bbba 100644 --- a/helpers/helpers.go +++ b/helpers/helpers.go @@ -593,8 +593,9 @@ func goType(pkg string, f *descriptor.FieldDescriptorProto) string { } func goZeroValue(f *descriptor.FieldDescriptorProto) string { + const nilString = "nil" if *f.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED { - return "nil" + return nilString } switch *f.Type { case descriptor.FieldDescriptorProto_TYPE_DOUBLE: @@ -614,13 +615,13 @@ func goZeroValue(f *descriptor.FieldDescriptorProto) string { case descriptor.FieldDescriptorProto_TYPE_STRING: return "\"\"" case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - return "nil" + return nilString case descriptor.FieldDescriptorProto_TYPE_BYTES: return "0" case descriptor.FieldDescriptorProto_TYPE_ENUM: - return "nil" + return nilString default: - return "nil" + return nilString } }