--- a/src/cmd/godoc/godoc.go 2011-07-20 09:14:34.000000000 +0200 +++ b/src/cmd/godoc/godoc.go 2011-07-20 09:38:03.949092477 +0200 @@ -80,6 +80,11 @@ pkgHandler httpHandler ) +const ( + docroot = "/usr/share/doc/packages/go-doc/doc" + srcroot = "/usr/share/go/" +) + func initHandlers() { paths := filepath.SplitList(*pkgPath) for _, t := range build.Path { @@ -90,9 +95,9 @@ } fsMap.Init(paths) - fileServer = http.FileServer(fsHttp) - cmdHandler = httpHandler{"/cmd/", filepath.Join(*goroot, "src", "cmd"), false} - pkgHandler = httpHandler{"/pkg/", filepath.Join(*goroot, "src", "pkg"), true} + fileServer = http.FileServer(http.Dir(docroot)) + cmdHandler = httpHandler{"/cmd/", filepath.Join(srcroot, "src/cmd"), false} + pkgHandler = httpHandler{"/pkg/", filepath.Join(srcroot, "src/pkg"), true} } func registerPublicHandlers(mux *http.ServeMux) { @@ -620,7 +625,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) @@ -799,13 +804,18 @@ } 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, "doc", "root.html"), "doc/root.html") return case "/doc/root.html":