Skip to content

Commit

Permalink
fix: Support FieldName with multiple underscores
Browse files Browse the repository at this point in the history
previously, any fields with more than one underscore would not be
correctly converted:

> short_filter becomes:    shortFilter
> a_longer_filter becomes: aLonger

this change hopefully fixes that by looking for any amount of
underscores rather than just one, so 'a_longer_filter' should now become
'aLongerFilter'.
  • Loading branch information
lgrn authored and Samuel Mutel committed Aug 10, 2023
1 parent 99e61f4 commit c0787ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions netbox/internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func FieldNameToStructName(k string) string {

split := strings.Split(k, "_")
k = split[0]
if len(split) > 1 {
r2 := []rune(split[1])
for i := 1; i < len(split); i++ {
r2 := []rune(split[i])
r2[0] = unicode.ToUpper(r2[0])
k = k + string(r2)
}
Expand Down

0 comments on commit c0787ca

Please sign in to comment.