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

Function resolveAlias

alias.go:49–69  ·  view source on GitHub ↗

resolveAlias attempts to resolve a named type to its underlying basic type (if possible). Pointers are expected to be indirected by this point.

(i any)

Source from the content-addressed store, hash-verified

47//
48// Pointers are expected to be indirected by this point.
49func resolveAlias(i any) (any, bool) {
50 if i == nil {
51 return nil, false
52 }
53
54 t := reflect.TypeOf(i)
55
56 // Not a named type
57 if t.Name() == "" || slices.Contains(kindNames, t.Name()) {
58 return i, false
59 }
60
61 resolve, ok := kinds[t.Kind()]
62 if !ok { // Not a supported kind
63 return i, false
64 }
65
66 v := reflect.ValueOf(i)
67
68 return resolve(v), true
69}

Callers 6

toNumberEFunction · 0.85
toUnsignedNumberEFunction · 0.85
ToBoolEFunction · 0.85
ToStringEFunction · 0.85
ToDurationEFunction · 0.85
TestAliasFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestAliasFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…