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
+6k Javascript : Get operating system and browser information
+9k Golang : Get SPF and DMARC from email headers to fight spam
+9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+18.4k Golang : How to remove certain lines from a file
+6.7k Golang : Skip or discard items of non-interest when iterating example
+15.1k Golang : package is not in GOROOT during compilation
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+9.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+14k Golang : Google Drive API upload and rename example
+7.3k Golang : How to iterate a slice without using for loop?
+17.9k Golang : Qt image viewer example
+18.5k Golang : Write file with io.WriteString