update wechatminiprogram

master
李光春 2 years ago
parent 35b96a04ee
commit 6215e893da

@ -23,8 +23,11 @@ func ToInt(s string) int {
// ToInt64 string到int64 // ToInt64 string到int64
func ToInt64(s string) int64 { func ToInt64(s string) int64 {
i, _ := strconv.ParseInt(s, 10, 64) i, err := strconv.ParseInt(s, 10, 64)
return i if err == nil {
return i
}
return int64(ToFloat64(s))
} }
// Replace 字符串替换 // Replace 字符串替换

@ -2,7 +2,6 @@ package gostring
import ( import (
"fmt" "fmt"
"log"
"strings" "strings"
"testing" "testing"
) )
@ -22,11 +21,10 @@ func TestName(t *testing.T) {
} }
func TestToInt64(t *testing.T) { func TestToInt64(t *testing.T) {
log.Println(ToInt64("120")) t.Log(ToInt64("120"))
log.Println(ToInt64("120.9")) t.Log(ToInt64("120.9"))
t.Log(strings.Contains("120", ","))
log.Println(strings.Contains("120", ",")) t.Log(strings.Contains("120,1", ","))
log.Println(strings.Contains("120,1", ","))
} }
func TestString(t *testing.T) { func TestString(t *testing.T) {

Loading…
Cancel
Save