Browse Source

InArray hinzugefügt

test
Klaus Wendel 4 years ago
parent
commit
fde0c2b704
  1. 21
      ebkTools.go

21
ebkTools.go

@ -4,6 +4,7 @@ import (
"bytes"
"math"
"path"
"reflect"
"regexp"
"runtime"
"strconv"
@ -108,3 +109,23 @@ func Ip4or6(s string) uint8 {
}
return 0
}
func InArray(val interface{}, array interface{}) (exists bool, index int) {
exists = false
index = -1
switch reflect.TypeOf(array).Kind() {
case reflect.Slice:
s := reflect.ValueOf(array)
for i := 0; i < s.Len(); i++ {
if reflect.DeepEqual(val, s.Index(i).Interface()) == true {
index = i
exists = true
return
}
}
}
return
}

Loading…
Cancel
Save