Skip to content

Commit

Permalink
fix: structs now handle both uppercase and lowercase first letters
Browse files Browse the repository at this point in the history
  • Loading branch information
Oudwins committed Sep 10, 2024
1 parent 2d10c92 commit 4fbc9c3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,15 @@ func (v *structProcessor) process(data any, dest any, path p.PathBuilder, ctx p.
if !fieldMeta.IsExported() {
continue
}
// TODO handle both upper & lowerCase first letter
// handle both upper & lowerCase first letter
fieldKey := string(unicode.ToLower(rune(fieldMeta.Name[0]))) + fieldMeta.Name[1:]
processor, ok := v.schema[fieldKey]
if !ok {
continue
fieldKey = string(unicode.ToUpper(rune(fieldMeta.Name[0]))) + fieldMeta.Name[1:]
processor, ok = v.schema[fieldKey]
if !ok {
continue
}
}
fieldTag, ok := fieldMeta.Tag.Lookup(p.ZogTag)
if ok {
Expand Down

0 comments on commit 4fbc9c3

Please sign in to comment.