v1.0.0
This commit is contained in:
commit
1329892e96
292 files changed
+43992
No files matched your search
@@ -0,0 +1,60 @@
|
||||
// Code generated by internal codegen utility; DO NOT EDIT.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func IsZeroValue(v any) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
switch rv.Kind() {
|
||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||
return rv.Len() == 0
|
||||
case reflect.Bool:
|
||||
return !rv.Bool()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return rv.Int() == 0
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
return rv.Uint() == 0
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return rv.Float() == 0
|
||||
case reflect.Interface, reflect.Pointer:
|
||||
return rv.IsNil()
|
||||
default:
|
||||
return rv.IsZero()
|
||||
}
|
||||
}
|
||||
|
||||
func IsRequiredParamMissing(v any) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
rv := reflect.ValueOf(v)
|
||||
switch rv.Kind() {
|
||||
case reflect.Bool:
|
||||
return false
|
||||
case reflect.Slice:
|
||||
return rv.IsNil()
|
||||
case reflect.Interface, reflect.Pointer:
|
||||
return rv.IsNil()
|
||||
default:
|
||||
return IsZeroValue(v)
|
||||
}
|
||||
}
|
||||
|
||||
func MissingRequiredParamsError(params []string) error {
|
||||
return fmt.Errorf("required params are missing: %s", strings.Join(params, ", "))
|
||||
}
|
||||
|
||||
func Strlen(s string) int {
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
||||
Reference in new issue
Block a user