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
+8.9k Golang : Get curl -I or head data from URL example
+11.4k Golang : Surveillance with web camera and OpenCV
+15k Golang : Get all local users and print out their home directory, description and group id
+16.6k Golang : Get own process identifier
+6.4k Elasticsearch : Shutdown a local node
+9.6k Golang : ffmpeg with os/exec.Command() returns non-zero status
+10.4k Golang : Allow Cross-Origin Resource Sharing request
+8.8k Golang : Capture text return from exec function example
+21.6k Golang : How to reverse slice or array elements order
+13.9k Golang : Check if a file exist or not
+16.2k Golang : Execute terminal command to remote machine example
+11.4k SSL : The certificate is not trusted because no issuer chain was provided