2 Star 0 Fork 0

403716045/gcore

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
int32.go 360 Bytes
Copy Edit Raw Blame History
xingang authored 2023-02-17 18:19 +08:00 . init
package number
import (
"strconv"
"strings"
)
type Int32 int32
func (t *Int32) UnmarshalJSON(data []byte) (err error) {
value := string(data)
value = strings.ReplaceAll(value, "\"", "")
if value == "" || value == "0" || value == "string" {
*t = 0
return nil
}
f, _ := strconv.ParseFloat(value, 32) //string转float32
*t = Int32(f)
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lv_baobao/gcore.git
git@gitee.com:lv_baobao/gcore.git
lv_baobao
gcore
gcore
3bf2efb9b087

Search