package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"
	"strconv"
)

func main() {
	router := NewRouter()

	port := flag.Int("port", 8080, "Port to run on")
	flag.Parse()

	if *port < 1 || *port > 65536 {
		log.Fatal(string(*port) + " is not a valid port number. Exiting.")
	}

	portString := ":" + strconv.Itoa(*port)

	fmt.Printf("Starting server on port %s", portString)

	log.Fatal(http.ListenAndServe(portString, router))
}

package main

import (
	"log"
	"net/http"
)

func main() {
	router := NewRouter()

	log.Fatal(http.ListenAndServe(":80", router))
}

--- 
+++ 
@@ -1,12 +1,26 @@
 package main
 
 import (
+	"flag"
+	"fmt"
 	"log"
 	"net/http"
+	"strconv"
 )
 
 func main() {
 	router := NewRouter()
 
-	log.Fatal(http.ListenAndServe(":80", router))
+	port := flag.Int("port", 8080, "Port to run on")
+	flag.Parse()
+
+	if *port < 1 || *port > 65536 {
+		log.Fatal(string(*port) + " is not a valid port number. Exiting.")
+	}
+
+	portString := ":" + strconv.Itoa(*port)
+
+	fmt.Printf("Starting server on port %s", portString)
+
+	log.Fatal(http.ListenAndServe(portString, router))
 }
Support specifying port as command-line flag on startup
