1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-06 03:27:27 +00:00

linting, 99% is not fine let's do it 100%

Former-commit-id: 45d246e8d14deb7c238e01e6a2b1648a9ddf39c0
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-01-04 16:34:04 +02:00
parent d946d11dff
commit 2e9cf2def7
5 changed files with 37 additions and 1 deletions

View File

@@ -58,10 +58,15 @@ func IsZero(v reflect.Value) bool {
return v.Interface() == zero.Interface()
}
// IndirectValue returns the reflect.Value that "v" points to.
// If "v" is a nil pointer, Indirect returns a zero Value.
// If "v" is not a pointer, Indirect returns v.
func IndirectValue(v reflect.Value) reflect.Value {
return reflect.Indirect(v)
}
// ValueOf returns the reflect.Value of "o".
// If "o" is already a reflect.Value returns "o".
func ValueOf(o interface{}) reflect.Value {
if v, ok := o.(reflect.Value); ok {
return v
@@ -70,6 +75,8 @@ func ValueOf(o interface{}) reflect.Value {
return reflect.ValueOf(o)
}
// ValuesOf same as `ValueOf` but accepts a slice of
// somethings and returns a slice of reflect.Value.
func ValuesOf(valuesAsInterface []interface{}) (values []reflect.Value) {
for _, v := range valuesAsInterface {
values = append(values, ValueOf(v))
@@ -77,6 +84,9 @@ func ValuesOf(valuesAsInterface []interface{}) (values []reflect.Value) {
return
}
// IndirectType returns the value of a pointer-type "typ".
// If "typ" is a pointer, array, chan, map or slice it returns its Elem,
// otherwise returns the typ as it's.
func IndirectType(typ reflect.Type) reflect.Type {
switch typ.Kind() {
case reflect.Ptr, reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: