From e0ccfda2ed2d5f7db6cb5b41d5d02d32f94e8180 Mon Sep 17 00:00:00 2001 From: Matt Burchett Date: Tue, 16 Oct 2018 15:06:46 -0500 Subject: [PATCH] bad code --- cmd/main.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cmd/main.go b/cmd/main.go index 7905807..e9fa6ea 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,5 +1,39 @@ package main +import ( + "flag" + "fmt" + "log" + "os" + "path/filepath" + "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() + + var files []string + err := filepath.Walk(location, func(path string, info os.FileInfo, err error) error { + files = append(files, path) + return nil + }) + if err != nil { + 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) + } + } }