2
我从*gin.Context
收到interface{}
类型值:错误转换接口{}为int去,杜松子酒
c.MustGet("account")
当我尝试转换到这个int
使用:
c.MustGet("account").(int)
我得到一个错误:
interface conversion: interface is float64, not int
此接口的值是1
。为什么我收到此错误?我在sql查询中使用这个值。由于sql语句失败,我无法将其转换为float64
。我怎样才能将它转换成int
?
http://stackoverflow.com/questions/8022389/convert-a-float64-to-an-int-in-go?rq=1 – kingSlayer