Skip to content

Commit

Permalink
Merge pull request #25 from Fenny/master
Browse files Browse the repository at this point in the history
⚒ add Default value
  • Loading branch information
Fenny authored Nov 5, 2020
2 parents ffae93e + c8d0cd0 commit ba358df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ func TrimRight(s string, cutset byte) string {
}
return s[:lenStr]
}

// Default returns the provided fallback value if string is empty
func Default(value string, defaultValue string) string {
if len(value) <= 0 {
return defaultValue
}
return value
}

0 comments on commit ba358df

Please sign in to comment.