Migrate to goconfig pkg
authorSebastien Binet <binet@farnsworth>
Thu, 16 Dec 2010 22:13:09 +0000 (23:13 +0100)
committerCarl Worth <cworth@cworth.org>
Wed, 26 Jan 2011 05:59:19 +0000 (15:59 +1000)
bindings/go/cmds/notmuch-addrlookup.go

index eae4b9a81c005a269bf01ca38310318ad18af785..a72e5301a38aca2b2ca8850f6f3966b7758a6354 100644 (file)
@@ -11,7 +11,8 @@ import "sort"
 
 // 3rd-party imports
 import "notmuch"
-import "github.com/jteeuwen/go-pkg-ini/ini"
+//import "github.com/jteeuwen/go-pkg-ini/ini"
+import "github.com/kless/goconfig/config"
 
 type mail_addr_freq struct {
        addr  string
@@ -178,7 +179,7 @@ type address_matcher struct {
 }
 
 func new_address_matcher() *address_matcher {
-       var cfg *ini.Config
+       var cfg *config.Config
        var err os.Error
 
        // honor NOTMUCH_CONFIG
@@ -187,13 +188,16 @@ func new_address_matcher() *address_matcher {
                home = os.Getenv("HOME")
        }
 
-       if cfg,err = ini.Load(path.Join(home, ".notmuch-config")); err != nil {
+       if cfg,err = config.ReadDefault(path.Join(home, ".notmuch-config")); err != nil {
                log.Exitf("error loading config file:",err)
        }
 
-       db_path := cfg.S("database", "path", "")
-       primary_email := cfg.S("user", "primary_email", "")
-       addrbook_tag := cfg.S("user", "addrbook_tag", "addressbook")
+       db_path,_ := cfg.String("database", "path")
+       primary_email,_ := cfg.String("user", "primary_email")
+       addrbook_tag,err := cfg.String("user", "addrbook_tag")
+       if err != nil {
+               addrbook_tag = "addressbook"
+       }
 
        self := &address_matcher{db:nil, 
                                 user_db_path:db_path,