In switch case expressions, the condition on case clause was not always properly evaluated. Reverse the order of case clause evaluations (as already done for if-else-if fashion), and fix the wiring to false-next and true-next nodes. Fixes #1126.
24 lines
273 B
Go
24 lines
273 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
err := errors.New("hello there")
|
|
|
|
switch true {
|
|
case err == nil:
|
|
break
|
|
case strings.Contains(err.Error(), "hello"):
|
|
fmt.Println("True!")
|
|
default:
|
|
fmt.Println("False!")
|
|
}
|
|
}
|
|
|
|
// Output:
|
|
// True!
|