How can I handle nil
return type in switch-case
operators?
func someFunc() interface{}{
if 5>2{
return nil
}else if something{
return 42
}
return nil
}
func main() {
switch someFunc().(type) {
case int:
case types.Nil:
fmt.Println("5>2")
}
}
This code prints nothing, but I expected "5>2". How should I do it properly? https://play.golang.org/p/vAdiH925LDl