---
title: "discarded-deferred-result"
description: "Detect deferred function results that are always discarded."
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.

# discarded-deferred-result

**Default severity:** `error`

The return values of a deferred call cannot be observed. A deferred function
literal that declares results usually contains a mistaken signature or should
store its result through another mechanism.

## Bad

```go
defer func() error {
	return cleanup()
}()
```

## Good

```go
defer func() {
	if err := cleanup(); err != nil {
		log.Printf("cleanup: %v", err)
	}
}()
```

Source: https://strider.gempir.com/lints/discarded-deferred-result/index.mdx
