refactor: minor changes and fixes
This commit is contained in:
parent
b791b84890
commit
dc8a9cff20
5 changed files with 11 additions and 25 deletions
|
|
@ -184,15 +184,14 @@ func LoadPluginsFromDir(dirpath string) (map[string]makeshift.Plugin, error) {
|
|||
|
||||
// helper to check for valid extensions
|
||||
var hasValidExt = func(path string) bool {
|
||||
var validExts = []string{".so", ".dylib", ".dll"}
|
||||
return slices.Contains(validExts, filepath.Ext(path))
|
||||
return slices.Contains([]string{".so", ".dylib", ".dll"}, filepath.Ext(path))
|
||||
}
|
||||
|
||||
// walk all files in directory only loading *valid* plugins
|
||||
err = filepath.Walk(dirpath, func(path string, info fs.FileInfo, err error) error {
|
||||
// skip trying to load generator plugin if directory or error
|
||||
// only try loading if file has .so extension
|
||||
if info.IsDir() || err != nil || hasValidExt(path) {
|
||||
if info.IsDir() || err != nil || !hasValidExt(path) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue