MCPcopy Index your code
hub / github.com/perkeep/perkeep / backslashEscape

Function backslashEscape

pkg/serverinit/serverinit_test.go:156–171  ·  view source on GitHub ↗

backslashEscape, on windows, changes all the slash separated paths (which match unixPathPattern, to omit the prefix handler paths) with escaped backslashes.

(b []byte)

Source from the content-addressed store, hash-verified

154// match unixPathPattern, to omit the prefix handler paths) with escaped
155// backslashes.
156func backslashEscape(b []byte) []byte {
157 if runtime.GOOS != "windows" {
158 return b
159 }
160 unixPaths := unixPathPattern.FindAll(b, -1)
161 if unixPaths == nil {
162 return b
163 }
164 var oldNew []string
165 for _, v := range unixPaths {
166 bStr := string(v)
167 oldNew = append(oldNew, bStr, strings.Replace(bStr, `/`, `\\`, -1))
168 }
169 r := strings.NewReplacer(oldNew...)
170 return []byte(r.Replace(string(b)))
171}
172
173func testConfig(name string, t *testing.T) {
174 wantedError := func() error {

Callers 3

configParserFunction · 0.85
testConfigFunction · 0.85
TestGenerateClientConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected