From 2ff320038dff260af7e122d2c521b62443f480fc Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 24 Sep 2024 16:43:39 -0500 Subject: [PATCH] clean up with new api --- cmd/main/main.go | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index b5fa188..5aa8848 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -19,10 +19,8 @@ import ( ) var ( - client *api.SyncClient - redisURL string - cronSchedule string - tzLocation *time.Location + client *api.SyncClient + tzLocation *time.Location ) func init() { @@ -31,13 +29,6 @@ func init() { if err != nil { fmt.Println(".env file not loaded") } - - // Load timezone - tzLocation, err = time.LoadLocation("America/Chicago") - if err != nil { - fmt.Println("Error loading location:", err) - os.Exit(1) - } } // primary is the main function that will be run by the scheduler @@ -60,14 +51,20 @@ func primary() error { } func main() { - redisURL = os.Getenv("REDIS_URL") - cronSchedule = os.Getenv("CRON_SCHEDULE") - - client = api.NewSyncClient(os.Getenv("TODOIST_API_KEY")) - + // redisURL := os.Getenv("REDIS_URL") + cronSchedule := os.Getenv("CRON_SCHEDULE") // opt, _ := redis.ParseURL(redisURL) // client := redis.NewClient(opt) + // Load timezone + tzLocation, err := time.LoadLocation("America/Chicago") + if err != nil { + fmt.Println("Error loading location:", err) + os.Exit(1) + } + + client = api.NewSyncClient(os.Getenv("TODOIST_API_KEY")) + // create a scheduler s, err := gocron.NewScheduler(gocron.WithLocation(tzLocation)) if err != nil {