标签: go

2 篇文章

json Unmarshal(non-pointer model.Submit)报错
这个报错:json: Unmarshal(non-pointer model.Submit)出现在语句:err := c.ShouldBind(codedata)说明在调用 ShouldBind 时传入了一个 非指针类型 的参数,而它需要一个指针类型来把 JSON 数据反序列化进去。问题详解:在 Go 的 encoding/json 包(Gin 的…
go生成随机数
在 Go 语言中,我们通常使用两种包来生成随机数,分别是用于生成伪随机数的 math/rand 包和用于生成加密安全随机数的 crypto/rand 包。使用 math/rand生成随机数math/rand 包提供了如 rand.Int()、rand.Intn(n)(生成 0 到 n-1 的整数)和 rand.Float64()(生成范围在 0.0…