Get form post value in Go
Practically almost every web page out there will ask you to fill a form to progress further. Most of these forms will post data to the server for further processing. Go has the capability to capture the posted form data as well. In this tutorial, we will show a simple function to capture the posted form data with
r.FormValue("form_data")
function
In the client browser:
<form action="http://website/process_form_data" method="post">
<input type="text" name="form_data" id="form_data" >
</form>
At the Go server :
func process_form_data(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
form_data := r.FormValue("form_data")
}
}
For more information, please refer to
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+5.2k Golang : How to search a list of records or data structures
+11k Golang : Determine if time variables have same calendar day
+40k Golang : How to check if a string contains another sub-string?
+5.4k Golang : Selection sort example
+7.1k Javascript : Put image into Chrome browser's console
+17.8k Golang : Check whether a network interface is up on your machine
+50.3k Golang : Check if item is in slice/array
+7.2k Golang : Configure Apache and NGINX to access your Go service example
+9.2k Golang : Compare files modify date example
+17.3k Golang : Get download file size
+15.3k Golang : How to extract links from web page ?
+5.1k Golang : List all packages and search for certain package