INNER CODE UNIT · Go
CompileRegex
ozontech/file.d · cfg/config.go:801
func CompileRegex(s string) (*regexp.Regexp, error) {
if s == "" {
return nil, fmt.Errorf(`regexp is empty`)
}
if s == "/" || s[0] != '/' || s[len(s)-1] != '/' {
return nil, fmt.Errorf(`regexp "%s" should be surrounded by "/"`, s)
}
return regexp.Compile(s[1 : len(s)-1])
}
// preallocSlicesFromJSON pre-sizes []struct config fields from the raw JSON.
func preallocSlicesFromJSON(v reflect.Value, object *simplejson.Json) error {
if object == nil {
return nil
}