Skip to content

Commit

Permalink
add int32tostring
Browse files Browse the repository at this point in the history
  • Loading branch information
lion committed Sep 12, 2019
1 parent a5c45f8 commit a8a0200
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion commonutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func CreateDir(dir string) error {
if !os.IsNotExist(err) {
return nil
}

return os.MkdirAll(dir, 0770)
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a8a0200

Please sign in to comment.