MCPcopy
hub / github.com/spf13/cast / indirect

Function indirect

indirect.go:16–37  ·  view source on GitHub ↗

From html/template/content.go Copyright 2011 The Go Authors. All rights reserved. indirect returns the value, after dereferencing as many times as necessary to reach the base type (or nil).

(i any)

Source from the content-addressed store, hash-verified

14// indirect returns the value, after dereferencing as many times
15// as necessary to reach the base type (or nil).
16func indirect(i any) (any, bool) {
17 if i == nil {
18 return nil, false
19 }
20
21 if t := reflect.TypeOf(i); t.Kind() != reflect.Ptr {
22 // Avoid creating a reflect.Value if it's not a pointer.
23 return i, false
24 }
25
26 v := reflect.ValueOf(i)
27
28 for v.Kind() == reflect.Ptr || (v.Kind() == reflect.Interface && v.Elem().Kind() == reflect.Ptr) {
29 if v.IsNil() {
30 return nil, true
31 }
32
33 v = v.Elem()
34 }
35
36 return v.Interface(), true
37}

Callers 11

toNumberFunction · 0.85
toNumberEFunction · 0.85
toUnsignedNumberFunction · 0.85
toUnsignedNumberEFunction · 0.85
ToBoolEFunction · 0.85
ToStringEFunction · 0.85
ToTimeInDefaultLocationEFunction · 0.85
ToDurationEFunction · 0.85
ToSliceEFunction · 0.85
toSliceEOkFunction · 0.85
TestIndirectFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIndirectFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…