Skip to content

Instantly share code, notes, and snippets.

@kalbasit
Last active October 19, 2015 17:52
Show Gist options
  • Save kalbasit/85b7853cd730bfaa7c93 to your computer and use it in GitHub Desktop.
Save kalbasit/85b7853cd730bfaa7c93 to your computer and use it in GitHub Desktop.
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