makecopy

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package makecopy defines an analyzer that detects make+copy patterns that can be replaced with slices.Clone.

Analyzer makecopy

makecopy: detect make+copy that can be simplified to slices.Clone

This analyzer flags two-statement patterns where a slice is allocated with make and immediately populated with copy:

dst := make([]T, len(src))
copy(dst, src)

These can be replaced with the simpler:

dst := slices.Clone(src)

Available since Go 1.21.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "makecopy",
	Doc:      "detect make+copy that can be simplified to slices.Clone",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      run,
}

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