Skip to content

Commit

Permalink
Merge pull request #73 from IAmAnubhavSaini/fix-72
Browse files Browse the repository at this point in the history
Fixes #72. Update URL, introduce error when ListenAndServe fail.
  • Loading branch information
xushiwei authored Feb 12, 2024
2 parents 624b416 + 2580bfa commit 37f0c49
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,19 @@ func handle(root string) func(w http.ResponseWriter, req *http.Request) {
}

var (
host = flag.String("host", "localhost:8000", "Serving host")
protocol = "http"
address = "localhost:8000"
host = flag.String("host", address, "Serving host")
)

func main() {
flag.Parse()
fmt.Println("Serving Go+ tutorial at", *host)
fmt.Printf("Serving Go+ tutorial at %s://%s\n", protocol, *host)
http.HandleFunc("/", handle("."))
http.ListenAndServe(*host, nil)
err := http.ListenAndServe(*host, nil)
if err != nil {
log.Fatalf("Failed to start server at %s://%s.\nError: %s.", protocol, *host, err)
}
}

// -----------------------------------------------------------------------------

0 comments on commit 37f0c49

Please sign in to comment.