From a8a0200779d5ffb4df6a34811f79025a92de9cd1 Mon Sep 17 00:00:00 2001 From: lion Date: Thu, 12 Sep 2019 14:39:12 +0800 Subject: [PATCH] add int32tostring --- commonutils/utils.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/commonutils/utils.go b/commonutils/utils.go index 620e468..3eb5eaa 100644 --- a/commonutils/utils.go +++ b/commonutils/utils.go @@ -482,7 +482,7 @@ func CreateDir(dir string) error { if !os.IsNotExist(err) { return nil } - + return os.MkdirAll(dir, 0770) } @@ -614,6 +614,28 @@ func FloatFromString(raw interface{}) (float64, error) { return flt, nil } +// Int32ToString format +func Int32ToString(n int32) string { + buf := [11]byte{} + pos := len(buf) + i := int64(n) + signed := i < 0 + if signed { + i = -i + } + for { + pos-- + buf[pos], i = '0'+byte(i%10), i/10 + if i == 0 { + if signed { + pos-- + buf[pos] = '-' + } + return string(buf[pos:]) + } + } +} + // IntFromString format func IntFromString(raw interface{}) (int, error) { str, ok := raw.(string)