Skip to content

Instantly share code, notes, and snippets.

@vmarmol
Created June 8, 2014 01:29
Show Gist options
  • Save vmarmol/ec389ac73e92f732aa80 to your computer and use it in GitHub Desktop.
Save vmarmol/ec389ac73e92f732aa80 to your computer and use it in GitHub Desktop.
Simple Go Webserver
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