ParseUserPatterns accepts an io.Reader pointing to a JSON user-pattern definition file, and returns a list of UserPatterns, and any error that occurred.
(r io.Reader)
| 210 | // definition file, and returns a list of UserPatterns, and any error that |
| 211 | // occurred. |
| 212 | func ParseUserPatterns(r io.Reader) (UserPatterns, error) { |
| 213 | out := make(UserPatterns, 0) |
| 214 | |
| 215 | dec := json.NewDecoder(r) |
| 216 | err := dec.Decode(&out) |
| 217 | if err != nil { |
| 218 | return out, err |
| 219 | } |
| 220 | |
| 221 | for _, p := range out { |
| 222 | err = p.ParseRegex() |
| 223 | if err != nil { |
| 224 | return out, err |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | return out, nil |
| 229 | } |