Compare commits

...

2 Commits

2 changed files with 15 additions and 1 deletions

View File

@ -15,6 +15,7 @@ const (
ParamStart = "start"
ParamEnd = "end"
ParamValue = "value"
ParamName = "name"
ParamEllipsis = "..."
ParamFilepath = "filepath"
ParamDirpath = "dirpath"

View File

@ -6,7 +6,9 @@ package expr
import (
"fmt"
"os"
"plugin"
"strings"
)
var pluginRegister map[string]*plugin.Plugin
@ -25,6 +27,17 @@ func pluginExists(name string) (exists bool) {
return
}
func makePluginName(name string) (decorated string) {
var template string
if execName, err := os.Executable(); err != nil || !strings.HasSuffix(execName, ".debug") {
template = "expr-%s-plugin.so"
} else {
template = "expr-%s-plugin.so.debug"
}
decorated = fmt.Sprintf(template, name)
return
}
func importPlugin( /*ctx ExprContext,*/ dirList []string, name string) (err error) {
var filePath string
var p *plugin.Plugin
@ -33,7 +46,7 @@ func importPlugin( /*ctx ExprContext,*/ dirList []string, name string) (err erro
var importFunc func(ExprContext)
var ok bool
decoratedName := fmt.Sprintf("expr-%s-plugin.so", name)
decoratedName := makePluginName(name)
if filePath, err = makeFilepath(decoratedName, dirList); err != nil {
return