hyperjumptech/grule-rule-engine

Windows: embedded source not working

almartino opened this issue · 0 comments

Describe the bug
Loading the rules through the code:
bundle := pkg.NewEmbeddedResourceBundle(rules, target, targetPattern)
Doesn't work in windows, below the affected code:

// pkg/embeddedResource.go
func (bundle *EmbeddedResourceBundle) loadPath(path string) ([]Resource, error) {
...
fulPath := filepath.Join(path, finfo.Name())
if finfo.IsDir() {
	gres, err := bundle.loadPath(fulPath)
	if err != nil {
		return nil, err
	}
	ret = append(ret, gres...)
} else {
	for _, pattern := range bundle.PathPattern {
		matched, err := doublestar.PathMatch(pattern, "/"+fulPath)
....
}

The variable fulPath under windows will be path\\subpath\\files\\etc. This problem is caused by
filepath.Join(path, finfo.Name()); can we use path.Join instead?

To Reproduce

Expected behavior
Embedded resource should work also in windows systems.

Additional context