MCPcopy Create free account
hub / github.com/LumaAI-API/Luma-API / Any2Int

Function Any2Int

common/utils.go:52–73  ·  view source on GitHub ↗
(data any)

Source from the content-addressed store, hash-verified

50}
51
52func Any2Int(data any) int {
53 if data == nil {
54 return 0
55 }
56 if valueAssert, ok := data.(float64); ok {
57 return int(valueAssert)
58 }
59 if valueAssert, ok := data.(int64); ok {
60 return int(valueAssert)
61 }
62 if valueAssert, ok := data.(int); ok {
63 return valueAssert
64 }
65 if valueAssert, ok := data.(*int); ok {
66 return *valueAssert
67 }
68 if valueAssert, ok := data.(string); ok {
69 valueAssertInt, _ := strconv.Atoi(valueAssert)
70 return valueAssertInt
71 }
72 return 0
73}
74
75func Any2Bool(data any) bool {
76 if data == nil {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected