January 2019
Beginner
132 pages
3h 14m
English
The form we used in the previous example used GET as a method. Hypothetically, if it were to use the POST method, there would be a slight difference in how the form is submitted. Instead of putting the values in the URL, you would need to build a request body instead. In the following example, the same form and search query will be structured as a POST request:
package mainimport ( "net/http" "net/url")func main() { data := url.Values{} data.Set("s", "Golang") response, err := http.PostForm("https://hub.packtpub.com/", data) // ... Continue processing the response ...}
In Go, you build a form submission using the url.Values struct. You can use this to set the inputs of the form—s=Golang in our case—and submit it using ...
Read now
Unlock full access