Debian Codegraph @

src/cmd/vendor/github.com/google/pprof/internal/report/package.go

raw
1 package report
2
3 import "regexp"
4
5 // pkgRE extracts package name, It looks for the first "." or "::" that occurs
6 // after the last "/". (Searching after the last / allows us to correctly handle
7 // names that look like "some.url.com/foo.bar".)
8 var pkgRE = regexp.MustCompile(`^((.*/)?[\w\d_]+)(\.|::)([^/]*)$`)
9
10 // packageName returns the package name of the named symbol, or "" if not found.
11 func packageName(name string) string {
12 m := pkgRE.FindStringSubmatch(name)
13 if m == nil {
14 return ""
15 }
16 return m[1]
17 }