1
2
3
4
5 package main
6
7
8 import "C"
9
10 import (
11 "reflect"
12
13 "testplugin/common"
14 )
15
16 func F() int {
17 _ = make([]byte, 1<<21)
18 return 3
19 }
20
21 func ReadCommonX() int {
22 return common.X
23 }
24
25 var Seven int
26
27 func call(fn func()) {
28 fn()
29 }
30
31 func g() {
32 common.X *= Seven
33 }
34
35 func init() {
36 Seven = 7
37 call(g)
38 }
39
40 type sameNameReusedInPlugins struct {
41 X string
42 }
43
44 type sameNameHolder struct {
45 F *sameNameReusedInPlugins
46 }
47
48 func UnexportedNameReuse() {
49 h := sameNameHolder{}
50 v := reflect.ValueOf(&h).Elem().Field(0)
51 newval := reflect.New(v.Type().Elem())
52 v.Set(newval)
53 }
54
55 func main() {
56 panic("plugin1.main called")
57 }
58
View as plain text