package util import ( "reflect" ) func IntInSlice(needle int, haystack[]int) (exists bool, index int) { exists = false index = -1 for i := 0; i < len(haystack); i++ { if haystack[i] == needle { return true, i } } return exists, index } //left here for historical reasons 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 }