---
title: "infinite-recursion"
description: "Detect recursive calls with no path to a function exit."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

## Bad

```go
func visit() { visit() }
```

## Good

```go
if done { return }; visit(next)
```

Source: https://strider.gempir.com/analyzers/infinite-recursion/index.mdx
