# M0002 undefined name (/docs/diagnostics/codes/m0002)

<Diagnostic code="M0002" />

It may be misspelled, declared in a file excluded by build tags, or belong to a package that is not imported.

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

<div className="code-pair">

```go title="The mistake"
fmt.Printn("hi")
n := strings.Count(s, "a") // strings not imported
```

```go title="Fixed"
import "strings" // [!code highlight]

fmt.Println("hi") // [!code highlight]
n := strings.Count(s, "a") // [!code highlight]
```

</div>

## The fix [#the-fix]

Fix the spelling, or import the package that declares it.

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