blob: 2431740b21610be25eebbf8433b4dfc8d8d22f56 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package logger
import (
"fmt"
"strconv"
)
// ToString converts interface to string
func ToString(v interface{}) string {
switch c := v.(type) {
case string:
return c
case int:
return strconv.FormatInt(int64(c), 10)
case int64:
return strconv.FormatInt(int64(c), 10)
case int32:
return strconv.FormatInt(int64(c), 10)
case int16:
return strconv.FormatInt(int64(c), 10)
case int8:
return strconv.FormatInt(int64(c), 10)
case uint:
return strconv.FormatUint(uint64(c), 10)
case uint64:
return strconv.FormatUint(uint64(c), 10)
case uint32:
return strconv.FormatUint(uint64(c), 10)
case uint16:
return strconv.FormatUint(uint64(c), 10)
case uint8:
return strconv.FormatUint(uint64(c), 10)
default:
return fmt.Sprintf("%v", c)
}
}
|