If you have an Handler function like the following, Then you can extract the Query string value (here its {param1}) using any of the two methods.
Method 1. It iterates through the query strings and prints the key and value.
Method 2. Directly extract the value using the mux Router object.
// Rounter for handling the request, Query string passed in {param1} variable
router.HandleFunc("/viewdemo/{param1}", GetDemoDetail).Methods("GET") func GetData(response http.ResponseWriter, request *http.Request) { // iterate throguth the object and extract key and value for k, v := range mux.Vars(request) { fmt.Printf("key=%v, value=%v", k, v) } //Use the mux router to extract the value of query string {param1} params := mux.Vars(request) objid := params["param1"] fmt.Println("Query string key value", objid) }
mux.Varsis for named parameters from your route.r.URL.Query().Get("param1")?