1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-30 08:57:07 +02:00
revive/fixtures/unreachable-code.go

38 lines
688 B
Go
Raw Normal View History

package fixtures
import (
"fmt"
"log"
"os"
)
func foo() int {
log.Fatalf("%s", "About to fail") // ignore
return 0 // MATCH /unreachable code after this statement/
return 1
Println("unreachable")
}
func f() {
fmt.Println("Hello, playground")
if true {
return // MATCH /unreachable code after this statement/
Println("unreachable")
os.Exit(2) // ignore
Println("also unreachable")
}
return // MATCH /unreachable code after this statement/
fmt.Println("Bye, playground")
}
func g() {
fmt.Println("Hello, playground")
if true {
return // ignore if next stmt is labeled
label:
os.Exit(2) // ignore
}
fmt.Println("Bye, playground")
}