Updated README and cleaned up output

This commit is contained in:
Tom Jowitt 2017-06-04 19:34:13 +10:00
parent edf99b52c0
commit 3d9abde17a
3 changed files with 16 additions and 6 deletions

View file

@ -10,12 +10,12 @@ import (
"time"
)
// Files contains the list of files we want to clean
// Files contains the list of files we want to delete
type Files struct {
FileList []File `json:"files"`
}
// File is an individual file we wish to remove from Slack
// File is an individual file we wish to delete from Slack
type File struct {
ID string `json:"id"`
}
@ -52,6 +52,7 @@ func main() {
log.Fatal(err)
}
count := 0
for _, file := range files.FileList {
req, err := http.NewRequest("GET", "https://slack.com/api/files.delete", nil)
if err != nil {
@ -66,7 +67,7 @@ func main() {
httpClient := &http.Client{}
resp, err := httpClient.Do(req)
if err != nil {
log.Fatal(err)
log.Println(err)
}
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
@ -74,6 +75,8 @@ func main() {
}
fmt.Println("File", file.ID, "successfully deleted")
count++
}
fmt.Println("Fin.", count, "files successfully deleted")
}