pkgURL returns a link to the godoc for the call.
(c *Call)
| 82 | |
| 83 | // pkgURL returns a link to the godoc for the call. |
| 84 | func 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 | // |
searching dependent graphs…