🏷️ Added GetMatch method for Files domain

This commit is contained in:
Maxim Lebedev 2023-11-09 07:59:18 +06:00
parent 6a4b77fb58
commit 1dbce57f2e
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
1 changed files with 15 additions and 1 deletions

View File

@ -1,4 +1,18 @@
package domain
// TODO(toby3d): search by glob pattern, type or name/id.
import "path"
// TODO(toby3d): search by type or name/id.
type Files []*File
func (f Files) GetMatch(pattern string) *File {
for i := range f {
if matched, err := path.Match(pattern, f[i].Path); err != nil || !matched {
continue
}
return f[i]
}
return nil
}