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

Function Writeable

internal/cheatpath/writeable.go:8–22  ·  view source on GitHub ↗

Writeable returns a writeable Path

(cheatpaths []Path)

Source from the content-addressed store, hash-verified

6
7// Writeable returns a writeable Path
8func Writeable(cheatpaths []Path) (Path, error) {
9
10 // iterate backwards over the cheatpaths
11 // NB: we're going backwards because we assume that the most "local"
12 // cheatpath will be specified last in the configs
13 for i := len(cheatpaths) - 1; i >= 0; i-- {
14 // if the cheatpath is not read-only, it is writeable, and thus returned
15 if !cheatpaths[i].ReadOnly {
16 return cheatpaths[i], nil
17 }
18 }
19
20 // otherwise, return an error
21 return Path{}, fmt.Errorf("no writeable cheatpaths found")
22}

Callers 3

cmdEditFunction · 0.92
TestWriteableOKFunction · 0.85
TestWriteableNotOKFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestWriteableOKFunction · 0.68
TestWriteableNotOKFunction · 0.68