MCPcopy Index your code
hub / github.com/apache/answer / InterfaceToString

Function InterfaceToString

pkg/converter/str.go:51–74  ·  view source on GitHub ↗

InterfaceToString converts data to string It will be used in template render

(data any)

Source from the content-addressed store, hash-verified

49// InterfaceToString converts data to string
50// It will be used in template render
51func InterfaceToString(data any) string {
52 switch t := data.(type) {
53 case int:
54 i := data.(int)
55 return strconv.Itoa(i)
56 case int8:
57 i := data.(int8)
58 return strconv.Itoa(int(i))
59 case int16:
60 i := data.(int16)
61 return strconv.Itoa(int(i))
62 case int32:
63 i := data.(int32)
64 return string(i)
65 case int64:
66 i := data.(int64)
67 return strconv.FormatInt(i, 10)
68 case string:
69 return data.(string)
70 default:
71 log.Warn("can't convert type:", t)
72 }
73 return ""
74}

Callers 1

http_funcmap.goFile · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected