Skip to content

Avoid false positive when slices are pre-allocated #25

@zlasd

Description

@zlasd

If a pre-allocated slice is declared by var statement and explicit type, it would be incorrectly reported as a candidate for pre-allocation.

For instance, the code snippet following would be reported.

package main

func main() {
	var s []int = make([]int, 0, 100)
	for i := range "Hello" {
		s = append(s, i)
	}
}

// Output:
// .\testdata\sample.go:4 Consider preallocating s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions