---
title: "no-init"
description: "Avoid implicit package initialization."
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.

# no-init

**Default severity:** `note`

**Configuration:** `severity` and path `excludes`

Reports package `init` functions. Initialization functions hide side effects
and ordering constraints from callers, which makes packages harder to test and
compose.

## Bad

```go
func init() {
	registerHandlers()
}
```

## Good

```go
func RegisterHandlers(registry *Registry) error {
	return registry.Register(defaultHandlers())
}
```

Call explicit setup from `main`, a constructor, or the test that needs it.
Explicit setup can return errors and makes dependencies visible.

## Suppress

```go
//strider:ignore no-init
func init() {
	// Required by an integration contract that cannot call setup explicitly.
}
```

Source: https://strider.gempir.com/lints/no-init/index.mdx
