I use DB.Get can get the specify key value, but can't get them by the Iterator
Author: donnolCreated Mar 6, 2021Updated Jun 9, 2023
the Iterator code is like that:
iter := lr.db.NewIterator(&util.Range{Start: []byte("/")}, &opt.ReadOptions{})
for iter.Next() {
key := iter.Key()
value := iter.Value()
nv, err := getValue(value)
if err != nil {
return nil, err
}
result = append(result, KeyValue{
Key: key,
Value: nv,
})
}
iter.Release()
if err := iter.Error(); err != nil {
return nil, err
}the Get code is like below:
data, err := lr.db.Get(key, &opt.ReadOptions{})
if err != nil {
return kv, err
}Source: syndtr/goleveldb