...
1
2
3
4
5 package main
6
7 import (
8 "log"
9 "plugin"
10
11 "testplugin/iface_i"
12 )
13
14 func main() {
15 a, err := plugin.Open("iface_a.so")
16 if err != nil {
17 log.Fatalf(`plugin.Open("iface_a.so"): %v`, err)
18 }
19 b, err := plugin.Open("iface_b.so")
20 if err != nil {
21 log.Fatalf(`plugin.Open("iface_b.so"): %v`, err)
22 }
23
24 af, err := a.Lookup("F")
25 if err != nil {
26 log.Fatalf(`a.Lookup("F") failed: %v`, err)
27 }
28 bf, err := b.Lookup("F")
29 if err != nil {
30 log.Fatalf(`b.Lookup("F") failed: %v`, err)
31 }
32 if af.(func() interface{})() != bf.(func() interface{})() {
33 panic("empty interfaces not equal")
34 }
35
36 ag, err := a.Lookup("G")
37 if err != nil {
38 log.Fatalf(`a.Lookup("G") failed: %v`, err)
39 }
40 bg, err := b.Lookup("G")
41 if err != nil {
42 log.Fatalf(`b.Lookup("G") failed: %v`, err)
43 }
44 if ag.(func() iface_i.I)() != bg.(func() iface_i.I)() {
45 panic("nonempty interfaces not equal")
46 }
47 }
48
View as plain text