diff --git a/examples/_server/main.go b/examples/_server/main.go index 3cbbd87ea..7d5544f57 100644 --- a/examples/_server/main.go +++ b/examples/_server/main.go @@ -32,7 +32,10 @@ import ( "time" ) -var port = flag.Int("port", 8000, "port number") +var ( + host = flag.String("host", "", "host name") + port = flag.Int("port", 8000, "port number") +) func init() { flag.Parse() @@ -165,6 +168,10 @@ func main() { http.HandleFunc("/main.js", serveMainJS) http.HandleFunc("/main.js.map", serveMainJSMap) http.HandleFunc("/", serveFileHandle) - fmt.Printf("http://localhost:%d/\n", *port) - log.Fatal(http.ListenAndServe("localhost:"+strconv.Itoa(*port), nil)) + if *host == "" { + fmt.Printf("http://127.0.0.1:%d/\n", *port) + } else { + fmt.Printf("http://%s:%d/\n", *host, *port) + } + log.Fatal(http.ListenAndServe(*host+":"+strconv.Itoa(*port), nil)) }