src/client/pkg/require/require.go
func oneOfEquals(sliceName string, slice interface{}, elem interface{}) (bool, error) {
	e := reflect.ValueOf(elem)
	sl := reflect.ValueOf(slice)
	if slice == nil || sl.IsNil() {
		sl = reflect.MakeSlice(reflect.SliceOf(e.Type()), 0, 0)
	}
	if sl.Kind() != reflect.Slice {
		return false, fmt.Errorf("\"%s\" must a be a slice, but instead was %s", sliceName, sl.Type().String())
	}
	if e.Type() != sl.Type().Elem() {
		return false, nil
	}
	arePtrs := e.Kind() == reflect.Ptr
	for i := 0; i < sl.Len(); i++ {
		if !arePtrs && reflect.DeepEqual(e.Interface(), sl.Index(i).Interface()) {
			return true, nil
		} else if arePtrs && reflect.DeepEqual(e.Elem().Interface(), sl.Index(i).Elem().Interface()) {
			return true, nil
		}
	}
	return false, nil
}
func oneOfEquals(sliceName string, slice interface{}, elem interface{}) (bool, error) {
	e := reflect.ValueOf(elem)
	sl := reflect.ValueOf(slice)
	if slice == nil || sl.IsNil() {
		sl = reflect.MakeSlice(reflect.SliceOf(e.Type()), 0, 0)
	}
	if sl.Kind() != reflect.Slice {
		return false, fmt.Errorf("\"%s\" must a be a slice, but instead was %s", sliceName, sl.Type().String())
	}
	if e.Type() != sl.Type().Elem() {
		return false, nil
	}
	arePtrs := e.Kind() == reflect.Ptr
	for i := 0; i < sl.Len(); i++ {
		if !arePtrs && reflect.DeepEqual(e.Interface(), sl.Index(i).Interface()) {
			return true, nil
		} else if arePtrs && reflect.DeepEqual(e.Elem().Interface(), sl.Index(i).Elem().Interface()) {
			return true, nil
		}
	}
	return false, nil
}
func oneOfEquals ( sliceName string , slice interface { } , elem interface { } ) ( bool , error ) { e := reflect . ValueOf ( elem ) sl := reflect . ValueOf ( slice ) if slice == nil || sl . IsNil ( ) { sl = reflect . MakeSlice ( reflect . SliceOf ( e . Type ( ) ) , 0 , 0 ) } if sl . Kind ( ) != reflect . Slice { return false , fmt . Errorf ( " \" \" " , sliceName , sl . Type ( ) . String ( ) ) } if e . Type ( ) != sl . Type ( ) . Elem ( ) { return false , nil } arePtrs := e . Kind ( ) == reflect . Ptr for i := 0 ; i < sl . Len ( ) ; i ++ { if ! arePtrs && reflect . DeepEqual ( e . Interface ( ) , sl . Index ( i ) . Interface ( ) ) { return true , nil } else if arePtrs && reflect . DeepEqual ( e . Elem ( ) . Interface ( ) , sl . Index ( i ) . Elem ( ) . Interface ( ) ) { return true , nil } } return false , nil }
// oneOfEquals is a helper function for EqualOneOf, OneOfEquals and NoneEquals, that simply
// returns a bool indicating whether 'elem' is in 'slice'. 'sliceName' is used for errors
oneOfEquals is a helper function for EqualOneOf OneOfEquals and NoneEquals that simply returns a bool indicating whether elem is in slice . sliceName is used for errors