Skip to content

Commit

Permalink
fix: rm IsNil
Browse files Browse the repository at this point in the history
  • Loading branch information
hui.wang committed Mar 11, 2022
1 parent 5ca119b commit 00623f2
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,40 +197,3 @@ func keyExists(k string, m map[string]interface{}) string {
}
return ""
}

func isNil(value interface{}, traceSource ...bool) bool {
if value == nil {
return true
}
var rv reflect.Value
if v, ok := value.(reflect.Value); ok {
rv = v
} else {
rv = reflect.ValueOf(value)
}
switch rv.Kind() {
case reflect.Chan,
reflect.Map,
reflect.Slice,
reflect.Func,
reflect.Interface,
reflect.UnsafePointer:
return !rv.IsValid() || rv.IsNil()

case reflect.Ptr:
if len(traceSource) > 0 && traceSource[0] {
for rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
if !rv.IsValid() {
return true
}
if rv.Kind() == reflect.Ptr {
return rv.IsNil()
}
} else {
return !rv.IsValid() || rv.IsNil()
}
}
return false
}

0 comments on commit 00623f2

Please sign in to comment.