cheat/internal/cheatpath/filter.go
Chris Lane e5114a3e76 Re-wrote from scratch in Golang
- Re-implemented the project in Golang, and deprecated Python entirely
- Implemented several new, long-requested features
- Refactored cheatsheets into a separate repository
2019-10-20 10:02:28 -04:00

20 lines
416 B
Go

package cheatpath
import (
"fmt"
)
// Filter filters all cheatpaths that are not named `name`
func Filter(paths []Cheatpath, name string) ([]Cheatpath, error) {
// if a path of the given name exists, return it
for _, path := range paths {
if path.Name == name {
return []Cheatpath{path}, nil
}
}
// otherwise, return an error
return []Cheatpath{}, fmt.Errorf("cheatpath does not exist: %s", name)
}