packagelevelmutableslicemap

package
v0.88.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package packagelevelmutableslicemap implements a Go analysis linter that flags package-level (file/package-scope) var declarations of slices or maps that are mutated from inside a function body via append re-assignment, index assignment, delete(), or wholesale re-assignment (e.g. assigning nil, a fresh literal, or a re-sliced expression back to the variable).

Package-level mutable slices/maps are shared across every goroutine and every call into the package for the lifetime of the process. Mutating one from inside a function — rather than storing the state on a struct or returning fresh values — risks data races under concurrent access and can leak state between unrelated calls.

Mutations inside a top-level init() function are not reported: init runs exactly once before any other code, so it is the idiomatic place to populate package-level state.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = analyzerutil.New("packagelevelmutableslicemap", "reports mutation (including wholesale re-assignment) of package-level slice/map variables from inside function bodies, which risks data races and cross-call state leaks", run)

Analyzer is the package-level-mutable-slice-map analysis pass.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL