github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/test/testdata/makezero.go (about)

     1  //golangcitest:args -Emakezero
     2  package testdata
     3  
     4  import "math"
     5  
     6  func Makezero() []int {
     7  	x := make([]int, math.MaxInt8)
     8  	return append(x, 1) // want "append to slice `x` with non-zero initialized length"
     9  }
    10  
    11  func MakezeroMultiple() []int {
    12  	x, y := make([]int, math.MaxInt8), make([]int, math.MaxInt8)
    13  	return append(x, // want "append to slice `x` with non-zero initialized length"
    14  		append(y, 1)...) // want "append to slice `y` with non-zero initialized length"
    15  }
    16  
    17  func MakezeroNolint() []int {
    18  	x := make([]int, math.MaxInt8)
    19  	return append(x, 1) //nolint:makezero // ok that we're appending to an uninitialized slice
    20  }