-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
43 lines (35 loc) · 675 Bytes
/
util.go
File metadata and controls
43 lines (35 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cucumber
import (
"os"
"path"
)
const (
featureFileExtension = ".feature"
)
func findFeatures(filepath string) ([]string, error) {
var files []string
fi, err := os.Stat(filepath)
if err != nil {
return nil, err
}
switch mode := fi.Mode(); {
case mode.IsDir():
f, err := os.Open(filepath)
if err != nil {
return nil, err
}
defer f.Close()
list, err := f.Readdir(-1)
if err != nil {
return nil, err
}
for _, fi := range list {
if path.Ext(fi.Name()) == featureFileExtension {
files = append(files, path.Join(filepath, fi.Name()))
}
}
case mode.IsRegular():
files = append(files, filepath)
}
return files, nil
}