From 55e0860a2f56e0f1c1869f4a7b606442edf2fa8b Mon Sep 17 00:00:00 2001 From: Arek Date: Sat, 18 Apr 2026 15:40:56 +0200 Subject: [PATCH] style: go vet applied --- cmd/gol/gol.go | 1 + gol/arena.go | 2 +- gol/arena_test.go | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/gol/gol.go b/cmd/gol/gol.go index 3a47329..ed0bb44 100644 --- a/cmd/gol/gol.go +++ b/cmd/gol/gol.go @@ -68,6 +68,7 @@ func game(initrandom bool) { // catch interrupt signals sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) + defer signal.Stop(sigs) // initialize screen term.StartFullscreen() diff --git a/gol/arena.go b/gol/arena.go index b99a543..cf328a0 100644 --- a/gol/arena.go +++ b/gol/arena.go @@ -103,7 +103,7 @@ func (a *Arena) processChunk(to *Arena, startY, endY int) { yCurrOffset := y * w yNextOffset := yNext * w - for x := 0; x < w; x++ { + for x := range w { // Precompute x indices xPrev := (x - 1 + w) % w xNext := (x + 1) % w diff --git a/gol/arena_test.go b/gol/arena_test.go index 958b94c..8876559 100644 --- a/gol/arena_test.go +++ b/gol/arena_test.go @@ -72,7 +72,7 @@ func TestRules(t *testing.T) { // Set center a.Set(1, 1, alive) // Set neighbors - for i := 0; i < activeNeighbors; i++ { + for i := range activeNeighbors { nx, ny := neighbors[i][0], neighbors[i][1] a.Set(nx, ny, true) } @@ -134,8 +134,8 @@ func BenchmarkNextGen(b *testing.B) { next := New(size, size) // Initialize with some pattern (e.g., random-ish) - for y := 0; y < size; y++ { - for x := 0; x < size; x++ { + for y := range size { + for x := range size { if (x+y)%2 == 0 { arena.Set(x, y, true) } @@ -143,7 +143,7 @@ func BenchmarkNextGen(b *testing.B) { } b.ResetTimer() - for i := 0; i < b.N; i++ { + for b.Loop() { arena.NextGen(next) arena, next = next, arena }