Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Jul 8, 2024
1 parent a168170 commit a7927ab
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions x/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,14 @@ func bindFlags(

if field.Type.Kind() == reflect.Struct {
nestedFlagPrefix := flag + "."
nestedEnvPrefix := env + "_"

flagPrefixDetails := strings.Split(field.Tag.Get("flag-prefix"), ",")
flagPrefix := flagPrefixDetails[0]

if flagPrefix != "" {
if flagPrefix := flagPrefixDetails[0]; flagPrefix != "" {
nestedFlagPrefix = flagPrefix + nestedFlagPrefix
}

nestedEnvPrefix := env + "_"

if envPrefix := field.Tag.Get("env-prefix"); envPrefix != "" {
nestedEnvPrefix = envPrefix + nestedEnvPrefix
}
Expand Down

0 comments on commit a7927ab

Please sign in to comment.