3000 explained code solutions for 75 technologies

golangHow to get query param from HTTP server

package main
import ( "fmt"; "net/http" )

func hi(w http.ResponseWriter, req *http.Request) {
  fmt.Fprintf(w, req.URL.Query().Get("test"))

func main() {
  http.HandleFunc("/hi", hi)
  http.ListenAndServe(":8222", nil)
}ctrl + c
package main

default package declaration

func main() {

declare main function that will be launched automatically


http package to work with http protocol


returns query string param value by specified name

"/hi", hi

handle /hi request with hi() function


launch HTTP server


port to listen HTTP server on