- refactor.
This commit is contained in:
@@ -3,6 +3,7 @@ package utils
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
@@ -86,6 +87,15 @@ func UnmarshalUseNumber(data []byte, result interface{}) error {
|
||||
return d.Decode(result)
|
||||
}
|
||||
|
||||
func MustMarshal(obj interface{}) []byte {
|
||||
byteArr, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("err when Marshal obj:%v", obj))
|
||||
}
|
||||
|
||||
return byteArr
|
||||
}
|
||||
|
||||
func Bool2String(value bool) string {
|
||||
if value {
|
||||
return "true"
|
||||
@@ -102,3 +112,11 @@ func Str2Int64(str string) int64 {
|
||||
retVal, _ := strconv.ParseInt(str, 10, 64)
|
||||
return retVal
|
||||
}
|
||||
|
||||
func Int64ToStr(value int64) string {
|
||||
return strconv.FormatInt(value, 10)
|
||||
}
|
||||
|
||||
func Int2Str(value int) string {
|
||||
return strconv.Itoa(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user