checking in some various work

This commit is contained in:
brent s. 2020-09-12 01:25:44 -04:00
parent ae39ee6adb
commit e92cd1adf8
Signed by: bts
GPG Key ID: 8C004C2F93481F6B

49
checks/checks.go Normal file
View File

@ -0,0 +1,49 @@
package checks

func All(l []interface{}) (int, bool) {
for idx, i := range l {
switch i.(type) {
case bool:
if i == false {
return idx, false
}
case string:
if i == "" {
return idx, false
}
case int8, int16, int32, int64, uint8, uint16, uint32, uint64, uintptr, float32, float64:
if i == 0 {
return idx, false
}
default:
if i == nil {
return idx, false
}
}
}
return 0, true
}

func Any(l []interface{}) (int, bool) {
for idx, i := range l {
switch i.(type) {
case bool:
if i == true {
return idx, true
}
case string:
if i != "" {
return idx, true
}
case int8, int16, int32, int64, uint8, uint16, uint32, uint64, uintptr, float32, float64:
if i != 0 {
return idx, true
}
default:
if i != nil {
return idx, true
}
}
}
return 0, false
}