github.com/stingnevermore/go@v0.0.0-20180120041312-3810f5bfed72/doc/articles/wiki/http-sample.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"net/http"
     7  )
     8  
     9  func handler(w http.ResponseWriter, r *http.Request) {
    10  	fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
    11  }
    12  
    13  func main() {
    14  	http.HandleFunc("/", handler)
    15  	log.Fatal(http.ListenAndServe(":8080", nil))
    16  }