github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/simple/s1020/testdata/src/example.com/CheckAssertNotNil/LintAssertNotNil.go (about)

     1  package pkg
     2  
     3  func fn(i interface{}, x interface{}) {
     4  	if _, ok := i.(string); ok && i != nil { //@ diag(`when ok is true, i can't be nil`)
     5  	}
     6  	if _, ok := i.(string); i != nil && ok { //@ diag(`when ok is true, i can't be nil`)
     7  	}
     8  	if _, ok := i.(string); i != nil || ok {
     9  	}
    10  	if _, ok := i.(string); i != nil && !ok {
    11  	}
    12  	if _, ok := i.(string); i == nil && ok {
    13  	}
    14  	if i != nil {
    15  		if _, ok := i.(string); ok { //@ diag(`when ok is true, i can't be nil`)
    16  		}
    17  	}
    18  	if i != nil {
    19  		// This gets flagged because of https://github.com/dominikh/go-tools/issues/1047
    20  		if _, ok := i.(string); ok { //@ diag(`when ok is true, i can't be nil`)
    21  		} else {
    22  			//
    23  		}
    24  	}
    25  	if i != nil {
    26  		if _, ok := i.(string); ok {
    27  		} else {
    28  			println()
    29  		}
    30  	}
    31  	if i != nil {
    32  		if _, ok := i.(string); ok {
    33  		}
    34  		println(i)
    35  	}
    36  	if i == nil {
    37  		if _, ok := i.(string); ok {
    38  		}
    39  	}
    40  	if i != nil {
    41  		if _, ok := i.(string); !ok {
    42  		}
    43  	}
    44  	if x != nil {
    45  		if _, ok := i.(string); ok {
    46  		}
    47  	}
    48  	if i != nil {
    49  		if _, ok := x.(string); ok {
    50  		}
    51  	}
    52  }