Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.api-usage

Assign the result of append

append returns a new slice; dropping the result loses the appended element.

#Metadata

Rule ID
go.correctness.unused-append-result
Severity
high
Confidence
0.9
Languages
go
Presets
strict
Stability
stable
Applies to
block
Tags
correctness, go, rules-catalog

#Why it matters

`append` may allocate a new backing array, so it always returns the resulting slice. Calling `append(s, x)` as a standalone statement silently throws the update away.

#Remediation

Assign the result back to the slice variable, e.g. `s = append(s, x)`.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/go/go.correctness.unused-append-result.rule.yaml.