plugins.go: If the main program's file name ends with '.debug', plugins will be loaded from file with name ending with '.debug'
This commit is contained in:
parent
9fb611aa20
commit
28f464c4dc
15
plugins.go
15
plugins.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user