int float转string
(i interface{})
| 7 | |
| 8 | // int float转string |
| 9 | func 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 | |
| 24 | func Str2Int(s string) int { |
| 25 | ret, err := strconv.Atoi(s) |
no outgoing calls