mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-28 22:39:05 +08:00
start tool for cleaning up old _repos dirs
This commit is contained in:
31
tools/clean-repos/main.go
Normal file
31
tools/clean-repos/main.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
files, err := ioutil.ReadDir("_repos/src")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
dirs, err := ioutil.ReadDir("_repos/src/" + f.Name())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for _, d := range dirs {
|
||||
if time.Now().Sub(d.ModTime()) > 30*24*time.Hour {
|
||||
path := "_repos/src/" + f.Name() + "/" + d.Name()
|
||||
log.Printf("Deleting %s...", path)
|
||||
os.RemoveAll(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user