MCPcopy Index your code
hub / github.com/maruel/panicparse / pkgURL

Function pkgURL

stack/html.go:84–114  ·  view source on GitHub ↗

pkgURL returns a link to the godoc for the call.

(c *Call)

Source from the content-addressed store, hash-verified

82
83// pkgURL returns a link to the godoc for the call.
84func pkgURL(c *Call) template.URL {
85 imp := c.ImportPath
86 // Check for vendored code first.
87 if i := strings.Index(imp, "/vendor/"); i != -1 {
88 imp = imp[i+8:]
89 }
90 ip := escape(imp)
91 if ip == "" {
92 return ""
93 }
94 url := template.URL("")
95 if c.Location == Stdlib {
96 // This always links to the latest release, past releases are not online.
97 // That's somewhat unfortunate.
98 url = "https://golang.org/pkg/"
99 } else {
100 // TODO(maruel): Leverage Location.
101 // Use pkg.go.dev when there's a version (go module) and godoc.org when
102 // there's none (implies branch master).
103 _, branch := getSrcBranchURL(c)
104 if branch == "master" || branch == "" {
105 url = "https://godoc.org/"
106 } else {
107 url = "https://pkg.go.dev/"
108 }
109 }
110 if c.Func.IsExported {
111 return url + ip + template.URL("#") + symbol(&c.Func)
112 }
113 return url + ip
114}
115
116// srcURL returns an URL to the sources.
117//

Callers 1

TestGetSrcBranchURLFunction · 0.85

Calls 3

escapeFunction · 0.85
getSrcBranchURLFunction · 0.85
symbolFunction · 0.85

Tested by 1

TestGetSrcBranchURLFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…