 cf32a7b706
			
		
	
	
		cf32a7b706
		
			
		
	
	
	
	
		
			
			makezero ensures that objects recognized as slices are initialized with length 0. By default, this is only required when we find a subsequent append to the object, but can also be enabled at all times as a way of discouraging the use of integer variables (i.e. "i") to index slices.
		
			
				
	
	
		
			13 lines
		
	
	
		
			315 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			13 lines
		
	
	
		
			315 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| //args: -Emakezero
 | |
| package testdata
 | |
| 
 | |
| func Makezero() []int {
 | |
| 	x := make([]int, 5)
 | |
| 	return append(x, 1) // ERROR "append to slice `x` with non-zero initialized length"
 | |
| }
 | |
| 
 | |
| func MakezeroNolint() []int {
 | |
| 	x := make([]int, 5)
 | |
| 	return append(x, 1) //nolint:makezero // ok that we're appending to an uninitialized slice
 | |
| }
 |