From 75ae7f72a782a87aca380b968315a5480870634e Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 14 Apr 2024 23:56:34 -0700 Subject: [PATCH] refactor: drop all unused code Signed-off-by: Christian Stewart --- features/unmarshal/unmarshal.go | 46 +-------------------------------- generator/pattern/match.go | 2 +- protohelpers/protohelpers.go | 2 +- 3 files changed, 3 insertions(+), 47 deletions(-) diff --git a/features/unmarshal/unmarshal.go b/features/unmarshal/unmarshal.go index b4fd4482..f3f66aa1 100644 --- a/features/unmarshal/unmarshal.go +++ b/features/unmarshal/unmarshal.go @@ -102,50 +102,6 @@ func (p *unmarshal) decodeFixed64(varName string, typeName string) { p.P(`iNdEx += 8`) } -func (p *unmarshal) declareMapField(varName string, nullable bool, field *protogen.Field) { - switch field.Desc.Kind() { - case protoreflect.DoubleKind: - p.P(`var `, varName, ` float64`) - case protoreflect.FloatKind: - p.P(`var `, varName, ` float32`) - case protoreflect.Int64Kind: - p.P(`var `, varName, ` int64`) - case protoreflect.Uint64Kind: - p.P(`var `, varName, ` uint64`) - case protoreflect.Int32Kind: - p.P(`var `, varName, ` int32`) - case protoreflect.Fixed64Kind: - p.P(`var `, varName, ` uint64`) - case protoreflect.Fixed32Kind: - p.P(`var `, varName, ` uint32`) - case protoreflect.BoolKind: - p.P(`var `, varName, ` bool`) - case protoreflect.StringKind: - p.P(`var `, varName, ` `, field.GoIdent) - case protoreflect.MessageKind: - msgname := field.GoIdent - if nullable { - p.P(`var `, varName, ` *`, msgname) - } else { - p.P(varName, ` := &`, msgname, `{}`) - } - case protoreflect.BytesKind: - p.P(varName, ` := []byte{}`) - case protoreflect.Uint32Kind: - p.P(`var `, varName, ` uint32`) - case protoreflect.EnumKind: - p.P(`var `, varName, ` `, field.GoIdent) - case protoreflect.Sfixed32Kind: - p.P(`var `, varName, ` int32`) - case protoreflect.Sfixed64Kind: - p.P(`var `, varName, ` int64`) - case protoreflect.Sint32Kind: - p.P(`var `, varName, ` int32`) - case protoreflect.Sint64Kind: - p.P(`var `, varName, ` int64`) - } -} - func (p *unmarshal) mapField(varName string, field *protogen.Field) { switch field.Desc.Kind() { case protoreflect.DoubleKind: @@ -808,7 +764,7 @@ func (p *unmarshal) message(proto3 bool, message *protogen.Message) { if fieldBit == required.Len() { panic("missing required field") } - p.P(`if hasFields[`, strconv.Itoa(int(fieldBit/64)), `] & uint64(`, fmt.Sprintf("0x%08x", uint64(1)<<(fieldBit%64)), `) == 0 {`) + p.P(`if hasFields[`, strconv.Itoa(fieldBit/64), `] & uint64(`, fmt.Sprintf("0x%08x", uint64(1)<<(fieldBit%64)), `) == 0 {`) p.P(`return `, p.Ident("fmt", "Errorf"), `("proto: required field `, field.Desc.Name(), ` not set")`) p.P(`}`) } diff --git a/generator/pattern/match.go b/generator/pattern/match.go index 2074bf1e..9565888c 100644 --- a/generator/pattern/match.go +++ b/generator/pattern/match.go @@ -188,7 +188,7 @@ MATCH: continue case '{': - startOfSegment = false + startOfSegment = false //nolint beforeIdx := patIdx patIdx++ closingIdx := indexMatchedClosingAlt(pattern[patIdx:], separator != '\\') diff --git a/protohelpers/protohelpers.go b/protohelpers/protohelpers.go index 64bde83e..2b2ed5b2 100644 --- a/protohelpers/protohelpers.go +++ b/protohelpers/protohelpers.go @@ -38,7 +38,7 @@ func SizeOfVarint(x uint64) (n int) { // SizeOfZigzag returns the size of the zigzag-encoded value. func SizeOfZigzag(x uint64) (n int) { - return SizeOfVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return SizeOfVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) //nolint } // Skip the first record of the byte slice and return the offset of the next record.