Skip to content

infinite-recursion

Detect recursive calls with no path to a function exit.

Updated View as Markdown

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.

Bad

func visit() { visit() }

Good

if done { return }; visit(next)
Navigation

Type to search…

↑↓ navigate↵ selectEsc close