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
+22.6k Golang : Strings to lowercase and uppercase example
+9.4k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+4.2k Javascript : How to show different content with noscript?
+9.6k Golang : Detect number of active displays and the display's resolution
+8.7k Golang : On lambda, anonymous, inline functions and function literals
+8.1k Android Studio : Rating bar example
+12.6k Golang : Sort and reverse sort a slice of bytes
+22.6k Golang : Set and Get HTTP request headers example
+12.3k Golang : Encrypt and decrypt data with x509 crypto
+18.6k Golang : Iterating Elements Over A List
+8.1k Golang : Get final or effective URL with Request.URL example
+10.1k Golang : Check a web page existence with HEAD request example