Skip to content

Commit

Permalink
fix snake case conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 18, 2024
1 parent fbe01f2 commit 594bd3e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/dynamic/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var dynamicStrategyConfigMetrics = map[string]any{}

func InitializeConfigMetrics(id, instanceId string, s types.StrategyID) error {
matchFirstCapRE := regexp.MustCompile("(.)([A-Z][a-z]+)")
matchAllCap := regexp.MustCompile("([a-z0-9])([A-Z])")

tv := reflect.TypeOf(s).Elem()
sv := reflect.Indirect(reflect.ValueOf(s))
Expand All @@ -37,7 +38,9 @@ nextStructField:
}

fieldName := tagAttrs[0]
fieldName = strings.ToLower(matchFirstCapRE.ReplaceAllString(fieldName, "${1}_${2}"))
fieldName = matchFirstCapRE.ReplaceAllString(fieldName, "${1}_${2}")
fieldName = matchAllCap.ReplaceAllString(fieldName, "${1}_${2}")
fieldName = strings.ToLower(fieldName)

isStr := false

Expand Down

0 comments on commit 594bd3e

Please sign in to comment.