Skip to content

Commit

Permalink
updated docs of badgerdb Key() and Value() APIs implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
alesforz committed Jul 11, 2024
1 parent b73d60d commit 709efff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion badger_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,22 @@ func (i *badgerDBIterator) Valid() bool {

// Key implements Iterator.
// The caller should not modify the contents of the returned slice.
// To work with the slice, make a copy and modify the copy instead.
// Instead, the caller should make a copy and work on the copy.
func (i *badgerDBIterator) Key() []byte {
if !i.Valid() {
panic("iterator is invalid")
}
return i.iter.Item().Key()
}

// Value implements Iterator.
// The caller should not modify the contents of the returned slice.
// Instead, the caller should make a copy and work on the copy.
func (i *badgerDBIterator) Value() []byte {
if !i.Valid() {
panic("iterator is invalid")
}

val, err := i.iter.Item().ValueCopy(nil)
if err != nil {
i.lastErr = err
Expand Down

0 comments on commit 709efff

Please sign in to comment.