http-sample.go 259 B

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