1 Star 1 Fork 1

mjun1833 / delve

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
plugintest2.go 764 Bytes
一键复制 编辑 原始数据 按行查看 历史
majun 提交于 2023-08-24 16:44 . chore: update module name
package main
import (
"fmt"
"gitee.com/mjun1833/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)
}
Go
1
https://gitee.com/mjun1833/delve.git
git@gitee.com:mjun1833/delve.git
mjun1833
delve
delve
v1.21.1

搜索帮助