摘要: // g可以去掉小数点后无效的0 fmt.Sprintf("%g", 123.00) 浮点数保留n位小数 func formatFloatNumber(f float64, m int) string { n := strconv.FormatFloat(f, 'f', -1, 64) if n = 阅读全文
posted @ 2022-08-21 13:04 夜灵杉 阅读(311) 评论(0) 推荐(0)
摘要: 在使用Update更新数据时一定要将where条件放在update前面,否则where不会生效,将更新所有数据 正确的写法 // 条件更新 db.Model(&User{}).Where("id= ?", ID).Update("name", "hello") 错误的写法 // 条件更新 db.Mo 阅读全文
posted @ 2022-08-21 12:58 夜灵杉 阅读(136) 评论(0) 推荐(0)