Source file
test/typeswitch3.go
Documentation: test
1
2
3
4
5
6
7
8
9
10
11 package main
12
13 import (
14 "io"
15 )
16
17 type I interface {
18 M()
19 }
20
21 func main() {
22 var x I
23 switch x.(type) {
24 case string:
25 println("FAIL")
26 }
27
28
29
30 var r io.Reader
31
32 _, _ = r.(io.Writer)
33
34 switch r.(type) {
35 case io.Writer:
36 }
37
38
39 switch _ := r.(type) {
40 }
41 }
42
43 func noninterface() {
44 var i int
45 switch i.(type) {
46 case string:
47 case int:
48 }
49
50 type S struct {
51 name string
52 }
53 var s S
54 switch s.(type) {
55 }
56 }
57
View as plain text