mirror of
https://github.com/cheat/cheat.git
synced 2025-12-28 18:02:06 +01:00
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
This commit is contained in:
19
internal/cheatpath/filter.go
Normal file
19
internal/cheatpath/filter.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user