From bdf6bcac460593b1be2eb103c0ea5ad2ba142f61 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Thu, 10 Sep 2015 19:58:00 +0200 Subject: Fix counts --- gwic.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gwic.go b/gwic.go index db35fca..5133557 100644 --- a/gwic.go +++ b/gwic.go @@ -12,12 +12,11 @@ import ( type queue struct { q []string - l int maxl int } func (q *queue) insert(s string) { - if len(q.q) < q.maxl { + if len(q.q) <= q.maxl { q.q = append(q.q, s) return } @@ -69,7 +68,7 @@ var ( kw string ) -const MAX int = 10 +const MAX int = 11 func main() { flag.Parse() @@ -81,7 +80,7 @@ func main() { tw = tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0) splitreg := regexp.MustCompile("[ \t\n]") - q := queue{maxl: MAX, q: make([]string, MAX), l: MAX} + q := queue{maxl: MAX, q: make([]string, MAX)} sc := make(chan string, 1000) reader := bufio.NewReader(os.Stdin) -- cgit v1.2.3