temporary tests

This commit is contained in:
Aliberk Sandıkçı 2023-09-01 19:52:53 +03:00
parent e2557da13f
commit c879b68f06
Signed by: asandikci
GPG key ID: 25C67A03B5666BC1
3 changed files with 58 additions and 16 deletions

View file

@ -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() {
}

Binary file not shown.

View file

@ -3,3 +3,7 @@ package addsymbol
func Symbol(a, b string) (interface{}, error) {
return symbol(a, b), nil
}
func TMPFUNC() {
}