Having the following code
var v interface{}
v = rune(1)
switch v.(type) {
case int32:
fmt.Println("int32")
case rune:
fmt.Println("rune")
}
I get a compilation error
tmp/sandbox193184648/main.go:14: duplicate case rune in type switch
previous case at tmp/sandbox193184648/main.go:12
If I instead wrap the rune in my own type, the type-switch compiles and works
type myrune rune
var v interface{}
v = myrune(1)
switch v.(type) {
case int32:
fmt.Println("int32")
case myrune:
fmt.Println("rune")
}
see https://play.golang.org/p/2lMRlpCLzX
Why is that? How can I distinguish a rune and int32 in a type-switch?