MCPcopy Index your code
hub / github.com/cheat/cheat / Filter

Function Filter

internal/cheatpath/filter.go:8–19  ·  view source on GitHub ↗

Filter filters all cheatpaths that are not named `name`

(paths []Path, name string)

Source from the content-addressed store, hash-verified

6
7// Filter filters all cheatpaths that are not named `name`
8func 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}

Callers 3

runFunction · 0.92
TestFilterSuccessFunction · 0.70
TestFilterFailureFunction · 0.70

Calls

no outgoing calls

Tested by 2

TestFilterSuccessFunction · 0.56
TestFilterFailureFunction · 0.56