HTTP server
Context
Section titled “Context”Go’s net/http package makes it easy to build HTTP servers. Use http.HandleFunc and http.ListenAndServe.
Example
Section titled “Example”A simple server that responds with “Hello, World”.
Code example
Section titled “Code example”package main
import ( "fmt" "net/http")
func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %s!", r.URL.Path[1:])}
func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil)}Hello, Alice!