From 40f80e8913d41b587e028da4226bd5c261923fc8 Mon Sep 17 00:00:00 2001 From: Miha Vrhovnik Date: Wed, 5 Aug 2020 08:50:08 +0200 Subject: [PATCH] Prevent index out of bunds error I'm reusing this driver for disque client... and get index out of bounds error because there really are just 2 items in array not 3. --- iterator.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iterator.go b/iterator.go index f6272d4..2f8bc2b 100644 --- a/iterator.go +++ b/iterator.go @@ -44,9 +44,10 @@ func (it *ScanIterator) Next(ctx context.Context) bool { } // Fetch next page. - if it.cmd.args[0] == "scan" { + switch it.cmd.args[0] { + case "scan", "qscan": it.cmd.args[1] = it.cmd.cursor - } else { + default: it.cmd.args[2] = it.cmd.cursor }