Filter filters all cheatpaths that are not named `name`
(paths []Path, name string)
| 6 | |
| 7 | // Filter filters all cheatpaths that are not named `name` |
| 8 | func Filter(paths []Path, name string) ([]Path, error) { |
| 9 | |
| 10 | // if a path of the given name exists, return it |
| 11 | for _, path := range paths { |
| 12 | if path.Name == name { |
| 13 | return []Path{path}, nil |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | // otherwise, return an error |
| 18 | return []Path{}, fmt.Errorf("cheatpath does not exist: %s", name) |
| 19 | } |
no outgoing calls