in order to prevent a huge amount of restarts i removed Fatalf and made it return normally I also made GetTime load the timezone once and just return the correct value as well as default to utc made the Auth function retry 3 times per account and send an error after that put time.Sleep into the correct loop in main.go initUpdate is in main now
28 lines
421 B
Go
28 lines
421 B
Go
package Untis
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
var Location *time.Location
|
|
|
|
func init() {
|
|
godotenv.Load("../.env")
|
|
timezone := os.Getenv("LOCATION_ENV")
|
|
if timezone == "" {
|
|
timezone = "UTC"
|
|
}
|
|
loc, err := time.LoadLocation(timezone)
|
|
if err != nil {
|
|
log.Printf("Failed to load timezone, set as UTC")
|
|
}
|
|
Location = loc
|
|
}
|
|
|
|
func GetTime() time.Time {
|
|
return time.Now().In(Location)
|
|
}
|