func convertSlice()

in cfn/encoding/unstringify.go [30:53]


func convertSlice(i interface{}, t reflect.Type, pointer bool) (reflect.Value, error) {
	s, ok := i.([]interface{})
	if !ok {
		return zeroValue, fmt.Errorf("Cannot convert %T to slice", i)
	}

	out := reflect.New(t)
	out.Elem().Set(reflect.MakeSlice(t, len(s), len(s)))

	for j, v := range s {
		val, err := convertType(t.Elem(), v)
		if err != nil {
			return zeroValue, err
		}

		out.Elem().Index(j).Set(val)
	}

	if !pointer {
		out = out.Elem()
	}

	return out, nil
}