Skip to content

Calling tx.Bucket(name) creates a new bucket if doesn't exist #464

@harryzcy

Description

@harryzcy
// Bucket retrieves a bucket by name.
// Returns nil if the bucket does not exist.
// The bucket instance is only valid for the lifetime of the transaction.
func (tx *Tx) Bucket(name []byte) *Bucket {
	return tx.root.Bucket(name)
}

The comment says Returns nil if the bucket does not exist. but actually new bucket is created if it does not exist.

Update: did some more testing, it seems it returns a bucket when a new db is created and opened, and actually returns nil after the bucket is explicitly deleted using DeleteBucket(name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions