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
+7.6k Golang : Copy map(hash table) example
+16.6k Golang : Check if directory exist and create if does not exist
+6.3k Golang : Gonum standard normal random numbers example
+5.2k Golang : Levenshtein distance example
+8.3k Golang : ISO8601 Duration Parser example
+7.9k Golang : Edge detection with Sobel method
+19.4k Golang : Convert(cast) string to rune and back to string example
+20.9k Golang : Time slice or date sort and reverse sort example
+11k Golang : List objects in AWS S3 bucket
+6.8k Golang : Build and compile multiple source files
+3.9k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+6.3k Android Studio : Import third-party library or package into Gradle Scripts