From 46e554e1888652cb68e192414430da05366c6c55 Mon Sep 17 00:00:00 2001 From: Carlo Strub Date: Mon, 20 Feb 2017 22:57:33 +0000 Subject: [PATCH] get lists of mail keys --- glide.lock | 8 +++++--- glide.yaml | 3 ++- main.go | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/glide.lock b/glide.lock index 3b43eb6..74eba69 100644 --- a/glide.lock +++ b/glide.lock @@ -1,4 +1,6 @@ -hash: e01a94e522ffe651c39d713d40e62bf312605f2504949b92a96797dab5faf2f3 -updated: 2017-02-20T22:22:08.238892736Z -imports: [] +hash: 0fbdb475136d5d29feb99b15dafd533580a8bbbf4fcfd801ddeeeb24e9a840c0 +updated: 2017-02-20T22:35:31.503897743Z +imports: +- name: github.com/luksen/maildir + version: 5297d9c3091c7d4891c9d4f6fa743d500c038d6f testImports: [] diff --git a/glide.yaml b/glide.yaml index b984994..6260f34 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,2 +1,3 @@ package: github.com/carlostrub/sisyphus -import: [] +import: +- package: github.com/luksen/maildir diff --git a/main.go b/main.go index 991663e..c174aac 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,42 @@ package main import ( - "github.com/spf13/viper" + "fmt" + "log" + + "github.com/luksen/maildir" +) + +var ( + // Maildirs holds a set of mail directories to handle. + Maildirs []string ) func main() { - viper.SetConfigName("sisyphus") + Maildirs = []string{"/usr/home/cs/Maildir.TEST"} + + var err error + var Bad, Good []string + + for _, dir := range Maildirs { + var keysBad, keysGood []string + keysBad, err = maildir.Dir(dir + "/.Junk").Keys() + if err != nil { + log.Fatal(err) + } + + Bad = append(Bad, keysBad...) + + keysGood, err = maildir.Dir(dir).Keys() + if err != nil { + log.Fatal(err) + } + + Good = append(Good, keysGood...) + } + + fmt.Println("Bad guys:") + fmt.Println(Bad) + fmt.Println("Good guys:") + fmt.Println(Good) }