pluginloader -- 用于简化调用 plugin 内的函数

fuhuizn · 2019-03-18 16:06:25 · 3245 次点击 · 大约8小时之前 开始浏览    置顶
这是一个创建于 2019-03-18 16:06:25 的主题,其中的信息可能已经有所发展或是发生改变。

源代码地址:

https://github.com/rocket049/pluginloader

用于简化调用 plugin 内的函数。

内容

type PluginLoader struct {
    ...
}
func (p *PluginLoader) Call(funcName string, p0 ...interface{}) (interface{}, error)

用法:

import "github.com/rocket049/pluginloader"

p, err := pluginloader.NewPluginLoader( "path_to_plugin" )
if err != nil {
    panic(err)
}
res, err := p.Call("NameOfFunc", p0,p1,p3,...)

注意:

被调用的函数可以无返回值,也可以返回1个返回值,或者1个返回值跟1个error

Call 的函数返回值格式只能是: ResType(ResType, error) -- ResType可以是任何类型。

当只有0个或1个返回值时,Call 返回的 error 始终是 nil


有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

3245 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传