mirror of
https://github.com/cheat/cheat.git
synced 2024-12-21 04:05:06 +01:00
e5114a3e76
- Re-implemented the project in Golang, and deprecated Python entirely - Implemented several new, long-requested features - Refactored cheatsheets into a separate repository
20 lines
416 B
Go
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)
|
|
}
|