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
+15.7k Golang : rune literal not terminated error
+12.2k Golang : Perform sanity checks on filename example
+5.5k Golang : Reclaim memory occupied by make() example
+21.4k Golang : Create and resolve(read) symbolic links
+15.9k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+6.2k Golang : Create new color from command line parameters
+10.1k Golang : Channels and buffered channels examples
+5.3k Golang : Customize scanner.Scanner to treat dash as part of identifier
+23.7k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+88.4k Golang : How to convert character to ASCII and back
+4.9k Which content-type(MIME type) to use for JSON data
+9.7k Golang : Sort and reverse sort a slice of floats