Source file
test/convert.go
1
2
3
4
5
6
7
8
9 package main
10
11 import "reflect"
12
13 func typeof(x interface{}) string { return reflect.TypeOf(x).String() }
14
15 func f() int { return 0 }
16
17 func g() int { return 0 }
18
19 type T func() int
20
21 var m = map[string]T{"f": f}
22
23 type A int
24 type B int
25
26 var a A = 1
27 var b B = 2
28 var x int
29
30 func main() {
31 want := typeof(g)
32 if t := typeof(f); t != want {
33 println("type of f is", t, "want", want)
34 panic("fail")
35 }
36
37 want = typeof(a)
38 if t := typeof(+a); t != want {
39 println("type of +a is", t, "want", want)
40 panic("fail")
41 }
42 if t := typeof(a + 0); t != want {
43 println("type of a+0 is", t, "want", want)
44 panic("fail")
45 }
46 }
47
View as plain text