From 8ed7a0c46b13bf7662462520d79cb305a427c690 Mon Sep 17 00:00:00 2001 From: Barpfotenbaer Date: Mon, 16 Nov 2020 13:24:18 +0100 Subject: [PATCH] InArray zu InSlice umbenannt --- ebkTools.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ebkTools.go b/ebkTools.go index f0e96a6..c365e41 100755 --- a/ebkTools.go +++ b/ebkTools.go @@ -12,6 +12,7 @@ package ebkTools import ( "bytes" "fmt" + "log" "math" "path" "reflect" @@ -120,13 +121,18 @@ func Ip4or6(s string) uint8 { return 0 } +// Find if value is contained by slice and return the position it was found func InArray(array interface{}, value interface{}) (exists bool, index int) { + log.Println("InArray() is deprecated an should be replaced by InSlice()") + return InSlice(array, value) +} +func InSlice(slice interface{}, value interface{}) (exists bool, index int) { exists = false index = -1 - switch reflect.TypeOf(array).Kind() { + switch reflect.TypeOf(slice).Kind() { case reflect.Slice: - s := reflect.ValueOf(array) + s := reflect.ValueOf(slice) for i := 0; i < s.Len(); i++ { if reflect.DeepEqual(value, s.Index(i).Interface()) == true {