diff options
author | Austin Clements <amdragon@MIT.EDU> | 2012-04-30 12:25:35 -0400 |
---|---|---|
committer | David Bremner <bremner@debian.org> | 2012-05-05 10:13:17 -0300 |
commit | 2e346b9e2adbca0e3dcd97bbf761a469068e91f9 (patch) | |
tree | 1a20d33c34309e943091d9cb9f642c14e94f0e93 /bindings | |
parent | ba5729421825e0ec9d38aa9d656553f329aa6f09 (diff) |
go: Update Go bindings for new notmuch_database_{open, create} signatures
This requires changing the return types of NewDatabase and
OpenDatabase to follow the standard Go convention for returning
errors.
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/go/pkg/notmuch.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/bindings/go/pkg/notmuch.go b/bindings/go/pkg/notmuch.go index de9de23..f9f86b5 100644 --- a/bindings/go/pkg/notmuch.go +++ b/bindings/go/pkg/notmuch.go @@ -86,21 +86,21 @@ const ( ) // Create a new, empty notmuch database located at 'path' -func NewDatabase(path string) *Database { +func NewDatabase(path string) (*Database, Status) { var c_path *C.char = C.CString(path) defer C.free(unsafe.Pointer(c_path)) if c_path == nil { - return nil + return nil, STATUS_OUT_OF_MEMORY } self := &Database{db:nil} - self.db = C.notmuch_database_create(c_path) - if self.db == nil { - return nil + st := Status(C.notmuch_database_create(c_path, &self.db)) + if st != STATUS_SUCCESS { + return nil, st } - return self + return self, st } /* Open an existing notmuch database located at 'path'. @@ -120,21 +120,21 @@ func NewDatabase(path string) *Database { * In case of any failure, this function returns NULL, (after printing * an error message on stderr). */ -func OpenDatabase(path string, mode DatabaseMode) *Database { +func OpenDatabase(path string, mode DatabaseMode) (*Database, Status) { var c_path *C.char = C.CString(path) defer C.free(unsafe.Pointer(c_path)) if c_path == nil { - return nil + return nil, STATUS_OUT_OF_MEMORY } self := &Database{db:nil} - self.db = C.notmuch_database_open(c_path, C.notmuch_database_mode_t(mode)) - if self.db == nil { - return nil + st := Status(C.notmuch_database_open(c_path, C.notmuch_database_mode_t(mode), &self.db)) + if st != STATUS_SUCCESS { + return nil, st } - return self + return self, st } /* Close the given notmuch database, freeing all associated |