reflection goes out of the window
This commit is contained in:
14
util/util.go
14
util/util.go
@ -4,6 +4,18 @@ 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
|
||||
@ -21,4 +33,4 @@ func InArray(val interface{}, array interface{}) (exists bool, index int) {
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user