From ae85cf1ceac66138f418702daea4ba4ab8a922cd Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Mon, 16 Oct 2023 02:47:14 -0700 Subject: [PATCH] Add gokrazy build tags --- cmd.go | 20 ++++++++++++++++++++ gokrazy.go | 32 ++++++++++++++++++++++++++++++++ main.go | 18 ------------------ 3 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 cmd.go create mode 100644 gokrazy.go diff --git a/cmd.go b/cmd.go new file mode 100644 index 0000000..09ee9ef --- /dev/null +++ b/cmd.go @@ -0,0 +1,20 @@ +//go:build !gokrazy +package main + +import ( + "flag" + "log" + "os" +) + +func main() { + flag.Parse() + if os.Getenv("GCD_USERNAME") == "" || os.Getenv("GCD_PASSWORD") == "" { + log.Println("Username and password not provided") + os.Exit(0) + } + + createDirs() + + downlod() +} diff --git a/gokrazy.go b/gokrazy.go new file mode 100644 index 0000000..b52fe34 --- /dev/null +++ b/gokrazy.go @@ -0,0 +1,32 @@ +//go:build gokrazy +package main + +import ( + "flag" + "log" + "os" + "time" + + "github.com/gokrazy/gokrazy" +) + + + +func main() { + gokrazy.WaitForClock() + flag.Parse() + if os.Getenv("GCD_USERNAME") == "" || os.Getenv("GCD_PASSWORD") == "" { + log.Println("Username and password not provided") + os.Exit(0) + } + for { + createDirs() + if shouldUpdate() { + downlod() + log.Println("update complete, waiting 1h to check again") + } else { + log.Println("It's too early, waiting 1h to check again") + } + time.Sleep(time.Hour) + } +} diff --git a/main.go b/main.go index 77d4074..9fc4545 100644 --- a/main.go +++ b/main.go @@ -278,21 +278,3 @@ func shouldUpdate() bool { log.Printf("can't update for another %v", timeTillUpdate) return false } - -func main() { - flag.Parse() - if os.Getenv("GCD_USERNAME") == "" || os.Getenv("GCD_PASSWORD") == "" { - log.Println("Username and password not provided") - os.Exit(0) - } - for { - createDirs() - if shouldUpdate() { - downlod() - log.Println("update complete, waiting 1h to check again") - } else { - log.Println("It's too early, waiting 1h to check again") - } - time.Sleep(time.Hour) - } -}