Converts the given value to a string.
Use fmt.Sprintf()
with the "%v"
format specifier to convert the given value to a string.
代码实现
import "fmt"
func Stringify(v interface{}) string {
return fmt.Sprintf("%v", v)
}
使用样例
Stringify(90) // "90"
Stringify(2.0) // "2.0"
Stringify(true) // "true"