Remove completed TODO remark. Optionally support .env files.
All checks were successful
Build Docker image / build (push) Successful in 1m4s

This commit is contained in:
Pieter Hollander 2024-02-20 15:50:50 +01:00
parent 2a92510c32
commit 703310f305
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg
2 changed files with 6 additions and 7 deletions

2
go.mod
View file

@ -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
)

11
main.go
View file

@ -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")