feat: passing of the port as arg

This commit is contained in:
efim 2023-10-04 09:24:22 +00:00
parent 2cb3cc7c35
commit f48d958a2c
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"embed" "embed"
"flag"
"fmt" "fmt"
"html/template" "html/template"
"io" "io"
@ -66,6 +67,11 @@ func main() {
} }
}) })
log.Print("starting server on default :8080") var port int
log.Fatal(http.ListenAndServe(":8080", nil)) flag.IntVar(&port, "p", 8080, "Specify port for server to start on")
flag.Parse()
address := fmt.Sprintf("localhost:%d", port)
log.Printf("starting server on %s", address)
log.Fatal(http.ListenAndServe(address, nil))
} }