map-dots/run/common.go
2023-08-11 14:53:28 +01:00

24 lines
622 B
Go

package run
import (
"fmt"
"os"
"git.fjla.uk/fred.boniface/map-dots/log"
)
func envCheck() {
log.Msg.Debug("reading Traccar credentials from environment")
user := os.Getenv("TRACCAR_USER")
pass := os.Getenv("TRACCAR_PASS")
url := os.Getenv("TRACCAR_URL")
if user == "" || pass == "" || url == "" {
fmt.Println("To use Traccar, you must set the environment variables:\n'TRACCAR_USER', 'TRACCAR_PASS', and for CLI use only 'TRACCAR_DEVID'")
os.Stdout.Sync() // Flush the output buffer
log.Msg.Fatal("Unable to read values from environment")
}
log.Msg.Debug("Traccar credentials exist in environment")
}