---
title: "add-constant"
description: "Suggest named constants for repeated literals."
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.

# add-constant

**Default severity:** `note`

Reports a string literal when it appears for the third time in one file. A
named constant keeps repeated protocol values, states, and keys consistent.

## Bad

```go
if state == "ready" { start() }
if next == "ready" { queue() }
if previous == "ready" { resume() }
```

## Good

```go
const stateReady = "ready"
if state == stateReady { start() }
```

Source: https://strider.gempir.com/lints/add-constant/index.mdx
