init code

This commit is contained in:
thuanle committed 2024-10-24 09:53:23 +07:00
1 parent a7559b3f9d
commit 92a63c7885
43 files changed
+1115

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
package convertx
import "strconv"
func Int642String(i int64) string {
return strconv.FormatInt(i, 10)
}
func String2Float64(s string, defValue ...float64) float64 {
f64, err := strconv.ParseFloat(s, 64)
if err != nil {
return defValue[0]
}
return f64
}
func String2Int(s string, defValue ...int) int {
i64, err := strconv.Atoi(s)
if err != nil {
return defValue[0]
}
return i64
}
func String2Int64(s string, defValue ...int64) int64 {
i64, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return defValue[0]
}
return i64
}