Housekeeper/cmd/main.go

45 lines
732 B
Go
Raw Normal View History

2018-10-16 17:16:58 +00:00
package main
2018-10-16 20:06:46 +00:00
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"time"
)
2018-10-17 17:21:16 +00:00
func isOlder(t time.Time, days int) bool {
hours := time.Duration(days*24) * time.Hour
return time.Now().Sub(t) > hours*time.Hour
}
2018-10-16 20:06:46 +00:00
2018-10-17 17:21:16 +00:00
func getFiles(location string, days int) error {
2018-10-16 20:06:46 +00:00
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)
}
for _, file := range files {
2018-10-17 17:21:16 +00:00
fmt.Println(file)
2018-10-16 20:06:46 +00:00
}
2018-10-16 17:16:58 +00:00
2018-10-17 17:21:16 +00:00
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)
2018-10-16 17:16:58 +00:00
}