🏷️ Added GetMatch method for Files domain
This commit is contained in:
parent
6a4b77fb58
commit
1dbce57f2e
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue