How to retrieve values from the URL in Go?

Viewed 99
2 Answers

You should find the query parameters by using this

campaign := r.URL.Query().Get("campaign")

You should get the query string value by this code:

http.HandleFunc("/signup", func(w http.ResponseWriter, r *http.Request) {
    q := r.URL.Query()
    campaign := q.Get("campaign")
    fmt.Println("campaign =>", campaign)
})
http.ListenAndServe(":8000", nil)
Related