github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/simple/s1009/testdata/src/example.com/CheckRedundantNilCheckWithLen/nil-len_generics.go (about)

     1  //go:build go1.18
     2  
     3  package pkg
     4  
     5  func fn1[T []int | *[4]int](a T) {
     6  	if a != nil && len(a) > 0 { // don't flag, because of the pointer
     7  	}
     8  }
     9  
    10  func fn2[T []int | []string | map[string]int](a T) {
    11  	if a != nil && len(a) > 0 { //@ diag(`should omit nil check`)
    12  	}
    13  }