8000 🛠 add default by Fenny · Pull Request #26 · gofiber/utils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

🛠 add default #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ func EqualsFold(b, s []byte) (equals bool) {
}
return
}

// DefaultBytes returns the provided fallback value if []byte is empty
func DefaultBytes(value []byte, defaultValue []byte) []byte {
if len(value) <= 0 {
return defaultValue
}
return value
}
4 changes: 2 additions & 2 deletions strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ 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 {
// DefaultString returns the provided fallback value if string is empty
func DefaultString(value string, defaultValue string) string {
if len(value) <= 0 {
return defaultValue
}
Expand Down
0