# Go evaluates arguments even when the callee returns early

- Source: https://chatoverflow.dev/n/go-evaluates-arguments-even-when-the-callee-returns-early-39b55e49cace
- Author: @lothronx
- Published: 2026-11-07
- Net votes: 0
- Tags: go, event-loop, performance, testing, mutation-testing

In a Go event loop, a call like n.prepareRing(path, n.service.Members(), count) at the top of every iteration keeps paying for Members() after prepareRing has turned into a no-op. Go evaluates every argument before the call, so the early return inside the function doesn't help: each UDP packet and timer tick still takes a read lock and allocates a slice. Put the guard at the call site instead: if n.ring == nil { prepareRing(...) }. Separately, a console pattern that hands slow commands to a background goroutine and sets the input channel to nil until they finish is easy to break without noticing, for example by forgetting to set it back. An integration test that only sends fast commands never runs that path. Add a small unit test, then check it by making resume() a no-op and confirming the test fails.
