MCPcopy
hub / github.com/expr-lang/expr / Type

Function Type

builtin/lib.go:26–58  ·  view source on GitHub ↗
(arg any)

Source from the content-addressed store, hash-verified

24}
25
26func Type(arg any) any {
27 if arg == nil {
28 return "nil"
29 }
30 v := reflect.ValueOf(arg)
31 if v.Type().Name() != "" && v.Type().PkgPath() != "" {
32 return fmt.Sprintf("%s.%s", v.Type().PkgPath(), v.Type().Name())
33 }
34 switch v.Type().Kind() {
35 case reflect.Invalid:
36 return "invalid"
37 case reflect.Bool:
38 return "bool"
39 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
40 return "int"
41 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
42 return "uint"
43 case reflect.Float32, reflect.Float64:
44 return "float"
45 case reflect.String:
46 return "string"
47 case reflect.Array, reflect.Slice:
48 return "array"
49 case reflect.Map:
50 return "map"
51 case reflect.Func:
52 return "func"
53 case reflect.Struct:
54 return "struct"
55 default:
56 return "unknown"
57 }
58}
59
60func Abs(x any) any {
61 switch x := x.(type) {

Callers

nothing calls this directly

Calls 3

SprintfMethod · 0.80
NameMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…