Merge pull request #628 from bep/patch-1

Fix prefix scan example
master
Ben Johnson 2016-12-27 14:06:03 -07:00 committed by GitHub
commit f57d45558d
1 changed files with 1 additions and 1 deletions

View File

@ -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)
}