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
+6.9k Golang : Get Alexa ranking data example
+5.5k List of Golang XML tutorials
+22.2k Golang : How to read JPG(JPEG), GIF and PNG files ?
+9k Golang : Generate random Chinese, Japanese, Korean and other runes
+18.6k Golang : How to make function callback or pass value from function as parameter?
+23.3k Find and replace a character in a string in Go
+17.5k Golang : Qt image viewer example
+16.2k CodeIgniter/PHP : Create directory if does not exist example
+10.3k Golang : Get local time and equivalent time in different time zone
+14k Golang : Get uploaded file name or access uploaded files
+50.5k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+51.6k Golang : How to get time in milliseconds?