Created
June 8, 2014 01:29
-
-
Save vmarmol/ec389ac73e92f732aa80 to your computer and use it in GitHub Desktop.
Simple Go Webserver
This file contains hidden or 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 | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
) | |
var argPort = flag.Int("port", 8080, "port to listen") | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hello world") | |
}) | |
addr := fmt.Sprintf(":%v", *argPort) | |
log.Fatal(http.ListenAndServe(addr, nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment