code: func (b *bucket) CreateBucketIfNotExists(key []byte) (database.Bucket, error) {
  	// Ensure transaction state is valid.
  	if err := b.tx.checkClosed(); err != nil {
  		return nil, err
  	}
  
  	// Ensure the transaction is writable.
  	if !b.tx.writable {
  		str := "create bucket requires a writable database transaction"
  		return nil, makeDbErr(database.ErrTxNotWritable, str, nil)
  	}
  
  	// Return existing bucket if it already exists, otherwise create it.
  	if bucket := b.Bucket(key); bucket != nil {
  		return bucket, nil
  	}
  	return b.CreateBucket(key)
  }
docs: // CreateBucketIfNotExists creates and returns a new nested bucket with the
  // given key if it does not already exist.
  //
  // Returns the following errors as required by the interface contract:
  //   - ErrBucketNameRequired if the key is empty
  //   - ErrIncompatibleValue if the key is otherwise invalid for the particular
  //     implementation
  //   - ErrTxNotWritable if attempted against a read-only transaction
  //   - ErrTxClosed if the transaction has already been closed
  //
  // This function is part of the database.Bucket interface implementation.