1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-03-01 00:35:28 +08:00

fix: fix lint issue

This commit is contained in:
dudaodong
2022-12-10 16:41:40 +08:00
parent 2725575d2f
commit 13bbe19ab2
17 changed files with 142 additions and 98 deletions

View File

@@ -97,38 +97,41 @@ func ToString(value any) string {
return ""
}
switch value.(type) {
switch val := value.(type) {
case float32:
return strconv.FormatFloat(float64(value.(float32)), 'f', -1, 32)
return strconv.FormatFloat(float64(val), 'f', -1, 32)
case float64:
return strconv.FormatFloat(value.(float64), 'f', -1, 64)
return strconv.FormatFloat(val, 'f', -1, 64)
case int:
return strconv.FormatInt(int64(value.(int)), 10)
return strconv.FormatInt(int64(val), 10)
case int8:
return strconv.FormatInt(int64(value.(int8)), 10)
return strconv.FormatInt(int64(val), 10)
case int16:
return strconv.FormatInt(int64(value.(int16)), 10)
return strconv.FormatInt(int64(val), 10)
case int32:
return strconv.FormatInt(int64(value.(int32)), 10)
return strconv.FormatInt(int64(val), 10)
case int64:
return strconv.FormatInt(value.(int64), 10)
return strconv.FormatInt(val, 10)
case uint:
return strconv.FormatUint(uint64(value.(uint)), 10)
return strconv.FormatUint(uint64(val), 10)
case uint8:
return strconv.FormatUint(uint64(value.(uint8)), 10)
return strconv.FormatUint(uint64(val), 10)
case uint16:
return strconv.FormatUint(uint64(value.(uint16)), 10)
return strconv.FormatUint(uint64(val), 10)
case uint32:
return strconv.FormatUint(uint64(value.(uint32)), 10)
return strconv.FormatUint(uint64(val), 10)
case uint64:
return strconv.FormatUint(value.(uint64), 10)
return strconv.FormatUint(val, 10)
case string:
return value.(string)
return val
case []byte:
return string(value.([]byte))
return string(val)
default:
newValue, _ := json.Marshal(value)
return string(newValue)
b, err := json.Marshal(val)
if err != nil {
return ""
}
return string(b)
// todo: maybe we should't supprt other type conversion
// v := reflect.ValueOf(value)