diff --git a/go.mod b/go.mod index 89a4322..accca65 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( require ( github.com/gorilla/websocket v1.5.0 // indirect - github.com/joho/godotenv v1.5.1 // indirect + github.com/joho/godotenv v1.5.1 golang.org/x/net v0.8.0 // indirect golang.org/x/sync v0.1.0 // indirect ) diff --git a/main.go b/main.go index db12f52..fe7414b 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,3 @@ -// TODO: Optimisation: only log dt1, dt2, rt1, rt2, g on change. package main import ( @@ -11,6 +10,7 @@ import ( _ "time/tzdata" mqtt "github.com/eclipse/paho.mqtt.golang" + "github.com/joho/godotenv" _ "github.com/lib/pq" ) @@ -74,11 +74,10 @@ type Payload struct { var db *sql.DB func main() { - // // Load environment variables from .env file if it exists - // err := godotenv.Load() - // if err != nil { - // log.Println("Error loading .env file:", err) - // } + // Load environment variables from .env file if it exists + if err := godotenv.Load(); err != nil { + log.Println("No .env file found or error loading .env file") + } // Connect to PostgreSQL pgConnStr := os.Getenv("PG_DB")