# M0110 possible nil dereference (/docs/diagnostics/codes/m0110)

A use dominated by a nil check is not reported.

## The mistake and the fix [#the-mistake-and-the-fix]

<div className="code-pair">

```go title="The mistake"
func find(id int) (*User, error) {
	if id == 0 {
		return nil, nil
	}
	...
}

u, err := find(id)
if err != nil {
	return err
}
fmt.Println(u.Name) // u is nil for id 0
```

```go title="Fixed"
u, err := find(id)
if err != nil {
	return err
}
if u == nil { // [!code highlight]
	return errNotFound // [!code highlight]
}
fmt.Println(u.Name) // [!code highlight]
```

</div>

## The fix [#the-fix]

Check for nil before the use, or make the function return an error instead of nil, nil.

See also [all error codes](/docs/diagnostics/codes) and [marmot explain](/docs/commands/explain).