문제

My test Handler code is here:

func defineHandler(w http.ResponseWriter, r *http.Request) {
    a := strconv.ParseInt(r.FormValue("aRows")[0:], 10, 64);
    b := r.FormValue("aRows");
    fmt.Fprintf(w, "aRows is: %s", b);
}

The error returned during the compile comes out as: "multiple-value strconv.ParseInt() in single-value context"

I believe it has to do with the format of information in the FormValue I just don't know how to alleviate that.

도움이 되었습니까?

해결책

It means that strconv.ParseInt has multiple return values (the int, and an error), so you need to do:

a, err := strconv.ParseInt(r.FormValue("aRows")[0:], 10, 64);
if err != nil {
  // handle the error in some way
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top