Skip to content

Commit

Permalink
Handle empty strings in flag name concatenation (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim authored May 1, 2024
1 parent 06f794b commit 8315816
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@ import (

// PrefixEnvVar returns the environment variable name with the given prefix and suffix
func PrefixEnvVar(prefix, suffix string) string {
if prefix == "" {
return suffix
}
if suffix == "" {
return prefix
}
return prefix + "_" + suffix
}

// PrefixFlag returns the flag name with the given prefix and suffix
func PrefixFlag(prefix, suffix string) string {
if prefix == "" {
return suffix
}
if suffix == "" {
return prefix
}
return prefix + "." + suffix
}

Expand Down

0 comments on commit 8315816

Please sign in to comment.