Skip to content

infinite-recursion

Default severity: error

A recursive call must have a path that reaches a function exit without making that call. Otherwise recursion continues until the goroutine stack exhausts available memory. Go does not optimize tail calls, so deliberate infinite recursion should be written as a loop.

Recursively starting a new goroutine is not reported because it does not grow one goroutine’s stack indefinitely.

func visit() { visit() }
if done { return }; visit(next)