checking in some various work
This commit is contained in:
parent
ae39ee6adb
commit
e92cd1adf8
49
checks/checks.go
Normal file
49
checks/checks.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user