refactor: use slices.Contains to simplify code

Signed-off-by: tanhuaan <tanhuaan@outlook.com>
This commit is contained in:
tanhuaan
2025-07-30 16:32:57 +08:00
parent 1470afb715
commit 0e79c4bd2a
2 changed files with 4 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"reflect"
"slices"
"strings"
)
@@ -95,12 +96,7 @@ func coalesce(v ...any) any {
// Returns:
// - bool: True if all values are non-empty, false otherwise
func all(v ...any) bool {
for _, val := range v {
if empty(val) {
return false
}
}
return true
return !slices.ContainsFunc(v, empty)
}
// anyNonEmpty checks if at least one value in a list is non-empty.