From 2505b9a7dcca1e5d9d80ebfc6be7afcd97ba02dd Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 15 Apr 2014 23:45:06 -0400 Subject: Return bucket from CreateBucket() functions. This commit changes the API for: Tx.CreateBucket() Tx.CreateBucketIfNotExists() Bucket.CreateBucket() Bucket.CreateBucketIfNotExists() These functions now return the *Bucket and error instead of just the error. --- cmd/bolt/import.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cmd/bolt/import.go') diff --git a/cmd/bolt/import.go b/cmd/bolt/import.go index 7554ae7..bcb7d2e 100644 --- a/cmd/bolt/import.go +++ b/cmd/bolt/import.go @@ -41,7 +41,8 @@ func Import(path string, input string) { } // Create the bucket if it doesn't exist. - if err := tx.CreateBucketIfNotExists(message.Key); err != nil { + b, err := tx.CreateBucketIfNotExists(message.Key) + if err != nil { return fmt.Errorf("create bucket: %s", err) } @@ -52,7 +53,6 @@ func Import(path string, input string) { } // Import all the values into the bucket. - b := tx.Bucket(message.Key) if err := importBucket(b, children); err != nil { return fmt.Errorf("import bucket: %s", err) } @@ -70,7 +70,8 @@ func importBucket(b *bolt.Bucket, children []*rawMessage) error { // Bucket messages are handled recursively. if child.Type == "bucket" { // Create the bucket if it doesn't exist. - if err := b.CreateBucketIfNotExists(child.Key); err != nil { + subbucket, err := b.CreateBucketIfNotExists(child.Key) + if err != nil { return fmt.Errorf("create bucket: %s", err) } @@ -81,7 +82,6 @@ func importBucket(b *bolt.Bucket, children []*rawMessage) error { } // Import subbucket. - subbucket := b.Bucket(child.Key) if err := importBucket(subbucket, subchildren); err != nil { return fmt.Errorf("import bucket: %s", err) } -- cgit v1.2.3