DEV Community

Divyanshu Shekhar
Divyanshu Shekhar

Posted on • Updated on

Golang Gorilla Schema HTML Forms

#go

Golang Gorilla Schema

func readForm(r *http.Request) *User {
    r.ParseForm()
    user := new(User)
    decoder := schema.NewDecoder()
    decodeErr := decoder.Decode(user, r.PostForm)
    if decodeErr != nil {
        log.Println("Error mapping parsed form data to struct : ", decodeErr)
    }
    return user

}
Enter fullscreen mode Exit fullscreen mode

First of all, learn about Golang HTML Forms then use gorilla schema.

Learn and get the full source code to get the form data using the Gorilla Schema in Golang.

Top comments (0)