boltdb/bolt — pull request #130 by benbjohnson (2014-04-16 03:50:53+00:00)
Title: Return bucket from CreateBucket() functions.

This commit changes the CreateBucket() functions to return a `*Bucket` reference.

The previous API:

```go
func (*Tx) CreateBucket([]byte) error
func (*Tx) CreateBucketIfNotExists() error
func (*Bucket) CreateBucket() error
func (*Bucket) CreateBucketIfNotExists() error
```

The new API:

```go
func (*Tx) CreateBucket([]byte) (*Bucket, error)
func (*Tx) CreateBucketIfNotExists() (*Bucket, error)
func (*Bucket) CreateBucket() (*Bucket, error)
func (*Bucket) CreateBucketIfNotExists() (*Bucket, error)
```

---

Not returning the bucket made sense before nested buckets was added because the top-level buckets represented something analogous to "tables" in relational databases. They were usually created once when the `DB` was first opened.

Buckets are no longer top-level only though. Because of this, accessing nested buckets almost always requires someone to call `CreateBucket*()` and then `Bucket()` immediately after.

---

/cc @mkobetic