1
我已經開始學習最近lang lang。我花了幾個小時,但無法弄清楚這有什麼問題。GO lang語法錯誤:意想不到的名稱,期待)
這裏是我的代碼:
func preference(cc *core.ComponentContext, w http.ResponseWriter, req *http.Request){
userID, err := core.PostParam(req, "user_id")
key, err := core.PostParam(req, "key")
value, err := core.PostParam(req, "value")
if err != nil {
cc.Error("Error reading the user id:", err.Error())
msg := fmt.Sprintf("user_id: %s", err.Error())
http.Error(w, msg, http.StatusBadRequest)
return
}
response :=models.UserPrefer(cc, userID int64, key string, value string) --> compile time error
b, err := json.Marshal(response)
if err != nil {
http.Error(w, "Internal Error", http.StatusInternalServerError)
return
}
fmt.Fprintf(w, string(b[:]))
}
以下錯誤拋出語法錯誤:意外的名字,期待) 它可能是簡單的,但我在圍棋郎知識有限我無法弄清楚。
爲什麼在調用UserPrefer時你有類型名稱'int64'和'string'? – Michael
在什麼位置拋出錯誤? – AJPennster
@AjPennster。在代碼中我提到編譯時錯誤。任何投票原因? – deadman