Question

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.

Était-ce utile?

La solution

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
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top