Skip to content

Commit

Permalink
refactor: drop all unused code
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Apr 15, 2024
1 parent e0016a1 commit 75ae7f7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 47 deletions.
46 changes: 1 addition & 45 deletions features/unmarshal/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(`}`)
}
Expand Down
2 changes: 1 addition & 1 deletion generator/pattern/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ MATCH:
continue

case '{':
startOfSegment = false
startOfSegment = false //nolint
beforeIdx := patIdx
patIdx++
closingIdx := indexMatchedClosingAlt(pattern[patIdx:], separator != '\\')
Expand Down
2 changes: 1 addition & 1 deletion protohelpers/protohelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 75ae7f7

Please sign in to comment.