Skip to content

Commit

Permalink
Fix flag parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Boernsman committed Sep 24, 2024
1 parent f8b22a5 commit 8613938
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"
)


const lifetime time.Duration = 24 * time.Hour

var devices struct {
Expand All @@ -32,6 +33,14 @@ func main() {
publicFolder := flag.String("public", "./public/", "Folder with the public files")
httpPort := flag.String("http-port", "8180", "Port for the HTTP server")

// Parse the command-line flags
flag.Parse()

// Check if the pubic folder exists
if _, err := os.Stat(*publicFolder); os.IsNotExist(err) {

Check failure on line 40 in main.go

View workflow job for this annotation

GitHub Actions / build

undefined: os
log.Fatalf("Publich folder does not exist")
}

devices.d = make([]Device, 0)

http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {})
Expand All @@ -42,6 +51,8 @@ func main() {
go cleanup()

fmt.Println("Listen on port", httpPort)
fmt.Println("Using public folder", publicFolder)

// Note: use TLS
log.Fatal(http.ListenAndServe(":" + *httpPort, nil))
}
Expand Down

0 comments on commit 8613938

Please sign in to comment.