zhangmeng
2020-01-20 7f325a2532bca346f77549b049851888e0e4255c
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
45
package master
 
import (
    "analysis/app"
    "analysis/logo"
    "plugin"
 
    "basic.com/libgowrapper/sdkstruct.git"
)
 
// Fetcher db
type Fetcher struct {
    fnInitDBAPI func(string, int, int, int, func(...interface{}))
    fnSDKInfo   func() []sdkstruct.SDKInfo
}
 
// NewFetcher new
func NewFetcher(soFile string) *Fetcher {
 
    plug, err := plugin.Open(soFile)
    if err != nil {
        logo.Errorln("Open: ", soFile, " error: ", err)
        return nil
    }
 
    fn, err := app.LoadFunc(plug, soFile, "InitDBAPI")
    if err != nil {
        logo.Infoln("Lookup Func InitDBAPI From File: ", soFile, " Error")
        return nil
    }
    fnInit := fn.(func(string, int, int, int, func(...interface{})))
 
    fn, err = app.LoadFunc(plug, soFile, "SDKInfo")
    if err != nil {
        logo.Infoln("Lookup Func SDKInfo From File: ", soFile, " Error")
        return nil
    }
 
    fnSDKInfo := fn.(func() []sdkstruct.SDKInfo)
 
    return &Fetcher{
        fnInitDBAPI: fnInit,
        fnSDKInfo:   fnSDKInfo,
    }
}