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.7k PHP : Convert CSV to JSON with YQL example
+16.3k Golang : How to check if input from os.Args is integer?
+13.3k Golang : Handle or parse date string with Z suffix(RFC3339) example
+5.9k Golang : Find change in a combination of coins example
+12.1k Golang : How to parse plain email text and process email header?
+5.4k Golang : Convert lines of string into list for delete and insert operation
+3.9k Java : Random alphabets, alpha-numeric or numbers only string generator
+11.9k How to tell if a binary(executable) file or web application is built with Golang?
+13.8k Golang : Query string with space symbol %20 in between
+7.2k Golang : Get Alexa ranking data example
+11.1k Golang : Replace a parameter's value inside a configuration file example