---
title: "append-to-sized-slice"
description: "Detect appends to slices created with a known positive length."
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.

# append-to-sized-slice

**Default severity:** `warning`

`make([]T, n)` with a compile-time positive `n` creates `n` existing zero
values. If the intent is to append up to `n` values, use `make([]T, 0, n)` so
the result does not begin with zeros. Runtime lengths are left alone when the
analyzer cannot prove that they are positive.

## Bad

```go
values := make([]int, count)
values = append(values, next)
```

## Good

```go
values := make([]int, 0, count)
values = append(values, next)
```

Source: https://strider.gempir.com/analyzers/append-to-sized-slice/index.mdx
