package main import ( "fmt" "log" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { value := r.FormValue("thing") if len(value) > 0 { fmt.Fprintf(w, "Got a value %s\n", value) return } if _, ok := r.Form["thing"]; ok { fmt.Fprintf(w, "Got the thing key but it was empty.\n") return } fmt.Fprintf(w, `
`) } func main() { http.HandleFunc("/", handler) log.Fatal(http.ListenAndServe(":8080", nil)) }