diff --git a/cmd/go-loader-test/plugin-manager.go b/cmd/go-loader-test/plugin-manager.go index 718dfdc..27e62a2 100644 --- a/cmd/go-loader-test/plugin-manager.go +++ b/cmd/go-loader-test/plugin-manager.go @@ -6,13 +6,22 @@ import ( "github.com/eh-steve/goloader/jit" ) +// plugins/addsymbol +type AddSymbol interface { + st() map[string]interface{} +} + +type STR struct { + ress func(a string, b string) (interface{}, error) +} + func PluginManager(params ...string) { conf := jit.BuildConfig{ - KeepTempFiles: false, // Files are copied/written to a temp dir to ensure it is writable. This retains the temporary copies - ExtraBuildFlags: []string{"-x"}, // Flags passed to go build command - BuildEnv: []string{"GOOS=darwin"}, // Env vars to set for go build toolchain - TmpDir: "/tmp/inner", // To control where temporary files are copied - DebugLog: false, // + KeepTempFiles: false, // Files are copied/written to a temp dir to ensure it is writable. This retains the temporary copies + ExtraBuildFlags: []string{"-x"}, // Flags passed to go build command + BuildEnv: []string{"GOOS=linux"}, // Env vars to set for go build toolchain + TmpDir: "/tmp/inner", // To control where temporary files are copied + DebugLog: false, // } loadable, err := jit.BuildGoPackage(conf, "plugins/tmptest/") @@ -38,10 +47,10 @@ func PluginManager(params ...string) { panic("Function signature was not what was expected") } - err = module.Unload() - if err != nil { - panic(err) - } + // err = module.Unload() + // if err != nil { + // panic(err) + // } // // @@ -60,21 +69,50 @@ func PluginManager(params ...string) { if err != nil { panic(err) } - switch f := symbols2["Symbol"].(type) { + // rst + switch Symbol := symbols2["Symbol"].(type) { + // rstrst case func(a, b string) (interface{}, error): - result, err := f("a", "b") - if err != nil { - panic(err) - } - fmt.Println(result) + // var mystruct SymbolPlugS + + var mystr STR + mystr.ress = Symbol + + // result, err := Im("a", "b") + // if err != nil { + // panic(err) + // } + fmt.Println(mystr.ress("a", "b")) + fmt.Println(&mystr.ress) + // fmt.Println(*mystr.ress) + // fmt.Println(*tmpresult) + // fmt.Println() default: - fmt.Println(f) + fmt.Println(symbols2) + panic("Function signature was not what was expected") } + // Symbol := symbols2["Symbol"] + // if f, ok := Symbol.(func(a, b string) (interface{}, error)); ok { + // // fmt.Println(HandlerType(f)("rst", "rstrtd")) + // fmt.Println(f("ast", "srd")) + // } + // for i, v := range symbols2 { + // fmt.Println(i, v) + // } + fmt.Println(&symbols2) + fmt.Println(symbols2) + fmt.Println() + fmt.Println(symbols) + fmt.Println(&symbols) err = module2.Unload() if err != nil { panic(err) } } + +func printsymbol() { + +} diff --git a/go-loader-test b/go-loader-test index 5a90d90..6a04847 100755 Binary files a/go-loader-test and b/go-loader-test differ diff --git a/plugins/addsymbol/symbol.go b/plugins/addsymbol/symbol.go index 3f477ac..6401563 100644 --- a/plugins/addsymbol/symbol.go +++ b/plugins/addsymbol/symbol.go @@ -3,3 +3,7 @@ package addsymbol func Symbol(a, b string) (interface{}, error) { return symbol(a, b), nil } + +func TMPFUNC() { + +}