diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-12-06 21:38:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-06 21:38:41 +0100 |
commit | 714f31f39eea377b2d31d38711cb9f97d0b58f50 (patch) | |
tree | b8433d5639f528000ea0fa7fdc5bd781dfe2254a /README.md | |
parent | Merge pull request #626 from timshannon/patch-1 (diff) | |
download | dedo-714f31f39eea377b2d31d38711cb9f97d0b58f50.tar.gz dedo-714f31f39eea377b2d31d38711cb9f97d0b58f50.tar.xz |
Fix prefix scan example
The example is correct in isolation, but if people just copy the loop, it will go into infinite loop when given an empty byte slice.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -395,7 +395,7 @@ db.View(func(tx *bolt.Tx) error { c := tx.Bucket([]byte("MyBucket")).Cursor() prefix := []byte("1234") - for k, v := c.Seek(prefix); bytes.HasPrefix(k, prefix); k, v = c.Next() { + for k, v := c.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, v = c.Next() { fmt.Printf("key=%s, value=%s\n", k, v) } |