From 847e49d1363e14d3eb732ff0a9e266b497acdaea Mon Sep 17 00:00:00 2001 From: "Stefan J. Betz" Date: Sun, 29 Sep 2024 10:38:19 +0200 Subject: [PATCH] implement print_expired() function --- main.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 5842126..842a211 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,10 @@ const ( CERT_CN ) +var TIME_90D = time.Now().Add(90 * 24 * time.Hour) +var TIME_30D = time.Now().Add(30 * 24 * time.Hour) +var TIME_NOW = time.Now() + type Certificate struct { Status string Expired *time.Time @@ -72,6 +76,19 @@ func (c *Certificates) process_line(line []string) { } } +func (c *Certificates) print_expired() { + for _, cert := range c.Certificates { + if cert.Expired.Before(TIME_NOW) { + } else if cert.Expired.Before(TIME_30D) { + fmt.Println("Oh Shit") + } else if cert.Expired.Before(TIME_90D) { + fmt.Println("Shitty Shit!") + fmt.Println(cert) + fmt.Println(*cert.CN) + } + } +} + func main() { file, err := os.Open(FILENAME) if err != nil { @@ -88,5 +105,5 @@ func main() { for _, line := range lines { cert_store.process_line(line) } - fmt.Println(cert_store.Certificates) + cert_store.print_expired() }