GoLang array_search

is this article helpful? yes | no
GoLang replacement for PHP's array_search [Golang Play | edit | history]
func ArraySearch(needle interface{}, hystack interface{}) (index int) {
	index = -1

	switch reflect.TypeOf(hystack).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(hystack)

		for i := 0; i < s.Len(); i++ {
			if reflect.DeepEqual(needle, s.Index(i).Interface()) == true {
				index = i
				return
			}
		}
	}
	return
}

PHP array_search

PHP original manual for array_search [ show | php.net ]