MCPcopy Create free account
hub / github.com/code-scan/Goal / Int2String

Function Int2String

Gconvert/num.go:9–22  ·  view source on GitHub ↗

int float转string

(i interface{})

Source from the content-addressed store, hash-verified

7
8// int float转string
9func Int2String(i interface{}) string {
10 switch i.(type) {
11 case int:
12 return strconv.FormatInt(int64(i.(int)), 10)
13 case int64:
14 return strconv.FormatInt(i.(int64), 10)
15 case float32:
16 return strconv.FormatFloat(float64(i.(float32)), 'f', -1, 32)
17 case float64:
18 return strconv.FormatFloat(i.(float64), 'f', -1, 64)
19 }
20 return ""
21
22}
23
24func Str2Int(s string) int {
25 ret, err := strconv.Atoi(s)

Callers 2

TestConvertFunction · 0.92
GetResultMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestConvertFunction · 0.74