Skip to content

Commit 30753dd

Browse files
authored
Merge pull request #26 from Fenny/master
🛠 add default
2 parents ba358df + f4c0d33 commit 30753dd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bytes.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@ func EqualsFold(b, s []byte) (equals bool) {
6868
}
6969
return
7070
}
71+
72+
// DefaultBytes returns the provided fallback value if []byte is empty
73+
func DefaultBytes(value []byte, defaultValue []byte) []byte {
74+
if len(value) <= 0 {
75+
return defaultValue
76+
}
77+
return value
78+
}

strings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func TrimRight(s string, cutset byte) string {
6161
return s[:lenStr]
6262
}
6363

64-
// Default returns the provided fallback value if string is empty
65-
func Default(value string, defaultValue string) string {
64+
// DefaultString returns the provided fallback value if string is empty
65+
func DefaultString(value string, defaultValue string) string {
6666
if len(value) <= 0 {
6767
return defaultValue
6868
}

0 commit comments

Comments
 (0)