-
Notifications
You must be signed in to change notification settings - Fork 3
/
regexes.go
33 lines (29 loc) · 845 Bytes
/
regexes.go
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
package porto
import (
"fmt"
"regexp"
"strings"
)
// StdExcludeDirRegexps is the standard directory exclusion list from golangci-lint.
// See https://github.com/golangci/golangci-lint/blob/master/pkg/packages/skip.go.
var StdExcludeDirRegexps = []*regexp.Regexp{
regexp.MustCompile("^vendor$"),
regexp.MustCompile("^third_party$"),
regexp.MustCompile("^testdata$"),
regexp.MustCompile("^examples$"),
regexp.MustCompile("^Godeps$"),
regexp.MustCompile("^builtin$"),
}
func GetRegexpList(regexps string) ([]*regexp.Regexp, error) {
var regexes []*regexp.Regexp
if len(regexps) > 0 {
for _, sfrp := range strings.Split(regexps, ",") {
sfr, err := regexp.Compile(sfrp)
if err != nil {
return nil, fmt.Errorf("failed to compile regex %q: %w", sfrp, err)
}
regexes = append(regexes, sfr)
}
}
return regexes, nil
}