Last active
October 19, 2015 17:52
-
-
Save kalbasit/85b7853cd730bfaa7c93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"path/filepath" | |
"regexp" | |
"time" | |
"github.com/jordan-wright/email" | |
) | |
func main() { | |
matches, err := filepath.Glob("/offlineimap/data/mail/**/*/*") | |
if err != nil { | |
panic(err) | |
} | |
var ( | |
begin = time.Now() | |
count int | |
) | |
for _, emf := range matches { | |
if ignore, _ := regexp.MatchString("/offlineimap/data/mail/.notmuch/.*", emf); ignore { | |
continue | |
} | |
count++ | |
f, err := os.Open(emf) | |
if err != nil { | |
log.Printf("error opening %q: %s", emf, err) | |
continue | |
} | |
if _, err := email.NewEmailFromReader(f); err != nil { | |
log.Printf("error reading %q: %s", emf, err) | |
} | |
f.Close() | |
} | |
fmt.Printf("it took %s to parse %d emails", time.Since(begin), count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment