Source file
test/alias1.go
1
2
3
4
5
6
7
8
9
10 package main
11
12 func main() {
13 var x interface{}
14
15 x = byte(1)
16 switch x.(type) {
17 case uint8:
18
19 default:
20 panic("byte != uint8")
21 }
22
23 x = uint8(2)
24 switch x.(type) {
25 case byte:
26
27 default:
28 panic("uint8 != byte")
29 }
30
31 rune32 := false
32 x = rune(3)
33 switch x.(type) {
34 case int:
35
36 case int32:
37
38 rune32 = true
39 default:
40 panic("rune != int and rune != int32")
41 }
42
43 if rune32 {
44 x = int32(4)
45 } else {
46 x = int(5)
47 }
48 switch x.(type) {
49 case rune:
50
51 default:
52 panic("int (or int32) != rune")
53 }
54 }
55
View as plain text