|
|
|
@ -4,11 +4,20 @@ import (
|
|
|
|
|
"crypto/hmac"
|
|
|
|
|
"crypto/sha256"
|
|
|
|
|
"encoding/hex"
|
|
|
|
|
"fmt"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"unicode/utf8"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ToString 转换成string
|
|
|
|
|
func ToString(value interface{}) string {
|
|
|
|
|
if value == nil {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
return fmt.Sprint(value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ToFloat64 string到float64
|
|
|
|
|
func ToFloat64(s string) float64 {
|
|
|
|
|
i, _ := strconv.ParseFloat(s, 64)
|
|
|
|
@ -88,6 +97,11 @@ func Split(s string, sep string) []string {
|
|
|
|
|
return strings.Split(s, sep)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Contains 判断字符串是否包含某个字符
|
|
|
|
|
func Contains(s, substr string) bool {
|
|
|
|
|
return strings.Contains(s, substr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NumericalToString(value interface{}) (string, bool) {
|
|
|
|
|
var val string
|
|
|
|
|
|
|
|
|
|