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