Simplify ToString function for types (avoid unnecessary casting)

pull/194/head
Emir Pasic 2 years ago
parent 9548245e86
commit a27d480bcc

@ -26,7 +26,7 @@ func ToString(value interface{}) string {
case int32: case int32:
return strconv.FormatInt(int64(value), 10) return strconv.FormatInt(int64(value), 10)
case int64: case int64:
return strconv.FormatInt(int64(value), 10) return strconv.FormatInt(value, 10)
case uint8: case uint8:
return strconv.FormatUint(uint64(value), 10) return strconv.FormatUint(uint64(value), 10)
case uint16: case uint16:
@ -34,11 +34,11 @@ func ToString(value interface{}) string {
case uint32: case uint32:
return strconv.FormatUint(uint64(value), 10) return strconv.FormatUint(uint64(value), 10)
case uint64: case uint64:
return strconv.FormatUint(uint64(value), 10) return strconv.FormatUint(value, 10)
case float32: case float32:
return strconv.FormatFloat(float64(value), 'g', -1, 64) return strconv.FormatFloat(float64(value), 'g', -1, 64)
case float64: case float64:
return strconv.FormatFloat(float64(value), 'g', -1, 64) return strconv.FormatFloat(value, 'g', -1, 64)
case bool: case bool:
return strconv.FormatBool(value) return strconv.FormatBool(value)
default: default:

Loading…
Cancel
Save