JOJ3/pkg/healthcheck/utils.go
周赵嘉程521432910016 cfc455e0fb
All checks were successful
build / build (push) Successful in 1m27s
build / trigger-build-image (push) Has been skipped
submodules sync / sync (push) Successful in 31s
fix(healthcheck): determine non-ascii file from git attributes (#69)
Co-authored-by: zzjc1234 <2359047351@qq.com>
Reviewed-on: #69
Reviewed-by: 张泊明518370910136 <bomingzh@sjtu.edu.cn>
Co-authored-by: 周赵嘉程521432910016 <zzjc123@sjtu.edu.cn>
Co-committed-by: 周赵嘉程521432910016 <zzjc123@sjtu.edu.cn>
2024-10-21 17:04:52 +08:00

30 lines
768 B
Go

package healthcheck
import (
"fmt"
"regexp"
)
// addExt appends the specified extension to each file name in the given fileList.
// It modifies the original fileList in place.
func addExt(fileList []string, ext string) {
for i, file := range fileList {
fileList[i] = file + ext
}
}
// getRegex compiles each regex pattern in the fileList into a []*regexp.Regexp slice.
// It returns a slice containing compiled regular expressions.
func getRegex(fileList []string) ([]*regexp.Regexp, error) {
var regexList []*regexp.Regexp
for _, pattern := range fileList {
regex, err := regexp.Compile("(?i)" + pattern)
if err != nil {
return nil, fmt.Errorf("Error compiling regex:%w", err)
}
regexList = append(regexList, regex)
}
return regexList, nil
}