鍍金池/ 問(wèn)答/人工智能  GO  網(wǎng)絡(luò)安全/ golang 中數(shù)據(jù)類(lèi)型的疑問(wèn)?

golang 中數(shù)據(jù)類(lèi)型的疑問(wèn)?

圖片描述

如圖,beego 框架中 this.Ctx.Input.Param(":pag") 返回的明明就是 string ,為什么錯(cuò)誤提示說(shuō)是 int ?

補(bǔ)充:
感謝回答,因?yàn)樵趈s和php中經(jīng)常這樣寫(xiě),我竟一點(diǎn)都不覺(jué)得截圖中這種寫(xiě)法有什么問(wèn)題。
而錯(cuò)誤提示讓我一直很困惑(主要是英語(yǔ)太差),我一直以為它提示我傳入?yún)?shù)的數(shù)據(jù)類(lèi)型不正確,原來(lái)是賦值時(shí)的數(shù)據(jù)類(lèi)型不正確。

pag:=this.Ctx.Input(":pag");//這里的pag是 string
pag=functions.ToInt(page);//這里返回的是 int,不能賦值給 string 類(lèi)型的pag
回答
編輯回答
膽怯

page:=functions.ToInt(pag)
this.list(page,"follow")

2017年9月9日 08:44