package main import ( "fmt" "net/http" "os" "strconv" "mcquay.me/web" ) func main() { static := "" if s := os.Getenv("STATIC"); s != "" { static = s } port := 8000 if os.Getenv("PORT") != "" { p, err := strconv.Atoi(os.Getenv("PORT")) if err != nil { fmt.Fprintf(os.Stderr, "couldn't parse port: %v\n", err) os.Exit(1) } port = p } sm := http.NewServeMux() web.NewServer(sm, static) if err := http.ListenAndServe(fmt.Sprintf(":%d", port), sm); err != nil { fmt.Fprintf(os.Stderr, "problem serving: %v\n", err) os.Exit(1) } }