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
+35.4k Golang : Get file last modified date and time
+34.1k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+8.2k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+7k Golang : Accessing dataframe-go element by row, column and name example
+21.4k Golang : Setting up/configure AWS credentials with official aws-sdk-go
+11.6k Golang : Clean formatting/indenting or pretty print JSON result
+17.3k Convert JSON to CSV in Golang
+6k Javascript : Generate random key with specific length
+11.6k Golang : Convert decimal number(integer) to IPv4 address
+33.3k Golang : All update packages with go get command
+21k Golang : How to read float value from standard input ?
+4.9k Golang : Issue HTTP commands to server and port example