[Golang] Get Query String of URL in net/http Handler

Get query string of URL in request handler of HTTP server via Go standard net/http Package.


Assume the URL of the HTTP request is


I want to get the value of name, i.e., john from the URL. How to get it in HTTP request handler of net/http?


import (

func handler(w http.ResponseWriter, r *http.Request) {
      name := r.URL.Query().Get("name")
      // the value of name is john

For more information about how to access the query string, see net/url package.

Tested on:

  • Ubuntu Linux 16.10
  • Go 1.8


[2][Golang] JSONP Server Implementation Code