1
2
3
4
5 package a
6
7 type I interface {
8 F()
9 }
10
11 type foo1 []byte
12 type foo2 []rune
13 type foo3 []uint8
14 type foo4 []int32
15 type foo5 string
16 type foo6 string
17 type foo7 string
18 type foo8 string
19 type foo9 string
20
21 func (f foo1) F() { return }
22 func (f foo2) F() { return }
23 func (f foo3) F() { return }
24 func (f foo4) F() { return }
25 func (f foo5) F() { return }
26 func (f foo6) F() { return }
27 func (f foo7) F() { return }
28 func (f foo8) F() { return }
29 func (f foo9) F() { return }
30
31 func Test1(s string) I { return foo1(s) }
32 func Test2(s string) I { return foo2(s) }
33 func Test3(s string) I { return foo3(s) }
34 func Test4(s string) I { return foo4(s) }
35 func Test5(s []byte) I { return foo5(s) }
36 func Test6(s []rune) I { return foo6(s) }
37 func Test7(s []uint8) I { return foo7(s) }
38 func Test8(s []int32) I { return foo8(s) }
39 func Test9(s int) I { return foo9(s) }
40
41 type bar map[int]int
42
43 func (b bar) F() { return }
44
45 func TestBar() I { return bar{1: 2} }
46
47 type baz int
48
49 func IsBaz(x interface{}) bool { _, ok := x.(baz); return ok }
50
51 type baz2 int
52
53 func IsBaz2(x interface{}) bool {
54 switch x.(type) {
55 case baz2:
56 return true
57 default:
58 return false
59 }
60 }
61
View as plain text