This repository has been archived on 2023-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
openskins/pluginmanager/helpers.go

31 lines
593 B
Go

package pluginmanager
import (
"os"
"path/filepath"
)
// GetPlugins gets plugin files in directory
func GetPlugins(pluginDir string) ([]string, error) {
pattern := "*.so"
var matches []string
err := filepath.Walk(pluginDir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
if matched, err := filepath.Match(pattern, filepath.Base(path)); err != nil {
return err
} else if matched {
matches = append(matches, path)
}
return nil
})
if err != nil {
return nil, err
}
return matches, nil
}