Skip to content

Instantly share code, notes, and snippets.

@eikenb
Last active January 15, 2016 18:28
Show Gist options
  • Save eikenb/69b135aa6943e0ba78ac to your computer and use it in GitHub Desktop.
Save eikenb/69b135aa6943e0ba78ac to your computer and use it in GitHub Desktop.
My go to http helloworld app.
package main
// Statically compile with;
// go build -a -tags netgo -installsuffix netgo helloworld.go
import (
"fmt"
"html"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
log.Println("call to;", html.EscapeString(r.URL.Path))
})
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment