File: plugintest2.go

package info (click to toggle)
delve 1.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,136 kB
  • sloc: ansic: 111,947; sh: 194; asm: 147; makefile: 43; python: 23
file content (44 lines) | stat: -rw-r--r-- 765 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main

import (
	"fmt"
	"github.com/go-delve/delve/_fixtures/internal/pluginsupport"
	"os"
	"plugin"
)

type asomething struct {
	n int
}

func (a *asomething) Callback(n int) int {
	return a.n + n
}

func (a *asomething) String() string {
	return "success"
}

var ExeGlobal = &asomething{2}

func must(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	plug1, err := plugin.Open(os.Args[1])
	must(err)
	plug2, err := plugin.Open(os.Args[2])
	must(err)
	fn1iface, err := plug1.Lookup("HelloFn")
	must(err)
	fn2iface, err := plug2.Lookup("TypesTest")
	must(err)
	fn1 := fn1iface.(func(int) string)
	fn2 := fn2iface.(func(pluginsupport.Something) pluginsupport.SomethingElse)
	a := fn1(3)
	b := fn2(&asomething{2})
	fmt.Println(a, b, ExeGlobal)
}