From 3ee2c13ba3d69c76b312932abc43d4c4541c5701 Mon Sep 17 00:00:00 2001 From: Matt Burchett Date: Wed, 17 Oct 2018 17:21:16 +0000 Subject: [PATCH] maybe --- cmd/main.go | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index e9fa6ea..965253f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -9,13 +9,12 @@ import ( "time" ) -func main() { - var location string - var days int - flag.StringVar(&location, "location", "", "location to scan") - flag.IntVar(&days, "days", 0, "days to poll") - flag.Parse() +func isOlder(t time.Time, days int) bool { + hours := time.Duration(days*24) * time.Hour + return time.Now().Sub(t) > hours*time.Hour +} +func getFiles(location string, days int) error { var files []string err := filepath.Walk(location, func(path string, info os.FileInfo, err error) error { files = append(files, path) @@ -25,15 +24,21 @@ func main() { log.Fatal(err) } - now := time.Now() - cutoff := now.Add(-int(days * time.Hour) - - fmt.Println(cutoff) - for _, file := range files { - if diff := now.Sub(files.ModTime()); diff > cutoff { - fmt.Println(diff) - } + fmt.Println(file) } + return err + +} + +func main() { + var location string + var days int + flag.StringVar(&location, "location", "", "location to scan") + flag.IntVar(&days, "days", 0, "days to poll") + flag.Parse() + + _ = getFiles(location, days) + }