From 714f31f39eea377b2d31d38711cb9f97d0b58f50 Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Tue, 6 Dec 2016 21:38:41 +0100 Subject: 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. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index 85810d9..e1b6535 100644 --- a/README.md +++ b/README.md @@ -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) } -- cgit v1.2.3