From 709effff45783c71e024401d408f6c5fe34f301c Mon Sep 17 00:00:00 2001 From: Alessandro Date: Thu, 11 Jul 2024 16:28:33 +0200 Subject: [PATCH] updated docs of badgerdb Key() and Value() APIs implementations. --- badger_db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/badger_db.go b/badger_db.go index d10f18e..4273a68 100644 --- a/badger_db.go +++ b/badger_db.go @@ -281,7 +281,7 @@ 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") @@ -289,10 +289,14 @@ func (i *badgerDBIterator) Key() []byte { 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