mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
30 lines
386 B
Go
30 lines
386 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func bad(x int) {
|
|
if x < 0 { // NOT OK
|
|
fmt.Println("x is negative")
|
|
} else {
|
|
fmt.Println("x is negative")
|
|
}
|
|
}
|
|
|
|
func good(x int) {
|
|
if x < 0 { // OK
|
|
fmt.Println("x is negative")
|
|
} else {
|
|
fmt.Println("x is non-negative")
|
|
}
|
|
}
|
|
|
|
func good2(xs []int, off int, b bool) []int {
|
|
if b {
|
|
return xs[off:]
|
|
} else {
|
|
return xs[:off]
|
|
}
|
|
}
|
|
|
|
func main() {}
|