go: update the addrlookup utility to go 1

Use the new built in error type that replaces os.Error, adapt the code
to the fact that strings.Split has just two arguments now.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
This commit is contained in:
Justus Winter 2012-05-09 13:15:18 +02:00 committed by David Bremner
parent 3760a79b3f
commit 9bf6eec1a5

View file

@ -86,7 +86,7 @@ func addresses_by_frequency(msgs *notmuch.Messages, name string, pass uint, addr
// "<?(?P<mail>\\b\\w+([-+.]\\w+)*\\@\\w+[-\\.\\w]*\\.([-\\.\\w]+)*\\w\\b)>?)" // "<?(?P<mail>\\b\\w+([-+.]\\w+)*\\@\\w+[-\\.\\w]*\\.([-\\.\\w]+)*\\w\\b)>?)"
pattern = `.*` + strings.ToLower(name) + `.*` pattern = `.*` + strings.ToLower(name) + `.*`
var re *regexp.Regexp = nil var re *regexp.Regexp = nil
var err os.Error = nil var err error = nil
if re,err = regexp.Compile(pattern); err != nil { if re,err = regexp.Compile(pattern); err != nil {
log.Printf("error: %v\n", err) log.Printf("error: %v\n", err)
return &freqs return &freqs
@ -103,7 +103,7 @@ func addresses_by_frequency(msgs *notmuch.Messages, name string, pass uint, addr
for _,header := range headers { for _,header := range headers {
froms := strings.ToLower(msg.GetHeader(header)) froms := strings.ToLower(msg.GetHeader(header))
//println(" froms: ["+froms+"]") //println(" froms: ["+froms+"]")
for _,from := range strings.Split(froms, ",", -1) { for _,from := range strings.Split(froms, ",") {
from = strings.Trim(from, " ") from = strings.Trim(from, " ")
match := re.FindString(from) match := re.FindString(from)
//println(" -> match: ["+match+"]") //println(" -> match: ["+match+"]")
@ -179,7 +179,7 @@ type address_matcher struct {
func new_address_matcher() *address_matcher { func new_address_matcher() *address_matcher {
var cfg *config.Config var cfg *config.Config
var err os.Error var err error
// honor NOTMUCH_CONFIG // honor NOTMUCH_CONFIG
home := os.Getenv("NOTMUCH_CONFIG") home := os.Getenv("NOTMUCH_CONFIG")