From bda5ef1fcfa1f6723077736d902cb0060bd49fe0 Mon Sep 17 00:00:00 2001 From: Harry Culpan Date: Tue, 30 Jun 2026 18:39:19 -0400 Subject: [PATCH] Fix PORT env var overwriting the 8080 fallback The old code set port='8080' then unconditionally overwrote it with os.Getenv("PORT"), which returns "" when unset, causing the server to bind to ':' instead of ':8080'. Co-Authored-By: Claude Sonnet 4.6 --- cmd/web/main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/web/main.go b/cmd/web/main.go index 7dbe670..72a33eb 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -16,14 +16,13 @@ import ( var appKey []byte func main() { - var port string + port := "8080" - err := godotenv.Load() - if err != nil { - port = "8080" + godotenv.Load() + + if p := os.Getenv("PORT"); p != "" { + port = p } - - port = os.Getenv("PORT") appKey = []byte(os.Getenv("APP_KEY")) if len(appKey) == 0 { log.Fatal("unable to load APP_KEY")