Last active
January 15, 2016 18:28
-
-
Save eikenb/69b135aa6943e0ba78ac to your computer and use it in GitHub Desktop.
My go to http helloworld app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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