MCPcopy Create free account
hub / github.com/bracesdev/errtrace / cleanGoRoot

Function cleanGoRoot

benchext/utils_for_test.go:11–24  ·  view source on GitHub ↗

cleanGoRoot is similar to tracetest, but deals with GOROOT paths. It replaces paths+line numbers for fixed values so we can use the output in an example test.

(s string)

Source from the content-addressed store, hash-verified

9// It replaces paths+line numbers for fixed values so we can use the
10// output in an example test.
11func cleanGoRoot(s string) string {
12 gorootPath := regexp.MustCompile("/.*/src/")
13 s = gorootPath.ReplaceAllString(s, "/goroot/src/")
14
15 fileLine := regexp.MustCompile(`/goroot/.*:[0-9]+`)
16 return fileLine.ReplaceAllStringFunc(s, func(path string) string {
17 file, _, ok := strings.Cut(path, ":")
18 if !ok {
19 return path
20 }
21
22 return file + ":0"
23 })
24}

Callers 1

Example_httpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected