Skip to content
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

✨ v3 (enhancement): add []byte support to utils.EqualFold #2029

Merged
merged 2 commits into from
Aug 19, 2022
Merged
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: 6 additions & 2 deletions utils/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ func TrimRight(s string, cutset byte) string {
return s[:lenStr]
}

// EqualFold tests ascii strings for equality case-insensitively
func EqualFold(b, s string) bool {
type byteSeq interface {
~string | ~[]byte
}

// EqualFold tests ascii strings or bytes for equality case-insensitively
func EqualFold[S byteSeq](b, s S) bool {
if len(b) != len(s) {
return false
}
Expand Down