go/go-godoc-path-locations.patch

53 lines
1.7 KiB
Diff

--- a/src/cmd/godoc/godoc.go 2011-03-08 18:46:40.906386884 +0100
+++ b/src/cmd/godoc/godoc.go 2011-03-08 19:10:03.880387209 +0100
@@ -78,12 +78,15 @@
pkgHandler httpHandler
)
+// for openSUSE packaging of godoc
+const docroot = "/usr/share/doc/packages/go-doc/doc"
+const srcroot = "/usr/share/go/"
func initHandlers() {
fsMap.Init(*pkgPath)
- fileServer = http.FileServer(*goroot, "")
- cmdHandler = httpHandler{"/cmd/", filepath.Join(*goroot, "src", "cmd"), false}
- pkgHandler = httpHandler{"/pkg/", filepath.Join(*goroot, "src", "pkg"), true}
+ fileServer = http.FileServer(docroot, "")
+ cmdHandler = httpHandler{"/cmd/", filepath.Join(srcroot, "src/cmd"), false}
+ pkgHandler = httpHandler{"/pkg/", filepath.Join(srcroot, "src/pkg"), true}
}
@@ -634,7 +637,7 @@
func readTemplate(name string) *template.Template {
- path := filepath.Join(*goroot, "lib", "godoc", name)
+ path := filepath.Join(*goroot, "lib/"+name)
if *templateDir != "" {
defaultpath := path
path = filepath.Join(*templateDir, name)
@@ -819,13 +822,19 @@
func serveFile(w http.ResponseWriter, r *http.Request) {
+ // openSUSE: serv docs from root of go-doc package install location
+ if strings.HasPrefix(r.URL.Path, "/doc/") {
+ http.Redirect(w, r, "/"+ r.URL.Path[len("/doc"):], http.StatusMovedPermanently)
+ return
+ }
+
relpath := r.URL.Path[1:] // serveFile URL paths start with '/'
- abspath := absolutePath(relpath, *goroot)
+ abspath := absolutePath(relpath, docroot)
// pick off special cases and hand the rest to the standard file server
switch r.URL.Path {
case "/":
- serveHTMLDoc(w, r, filepath.Join(*goroot, "doc", "root.html"), "doc/root.html")
+ serveHTMLDoc(w, r, filepath.Join(docroot, "root.html"), "root.html")
return
case "/doc/root.html":