]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/godoc: use virtual filesystem to implement -templates flag
authorAndrew Gerrand <adg@golang.org>
Tue, 27 Mar 2012 22:13:48 +0000 (09:13 +1100)
committerAndrew Gerrand <adg@golang.org>
Tue, 27 Mar 2012 22:13:48 +0000 (09:13 +1100)
R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/5921045

src/cmd/godoc/godoc.go
src/cmd/godoc/main.go

index f21c20496ce30daad08cd3e069448effc36992da..f6dc678b49d4b3159ea92126ae9f5587faa47646 100644 (file)
@@ -491,14 +491,6 @@ var fmap = template.FuncMap{
 
 func readTemplate(name string) *template.Template {
        path := "lib/godoc/" + name
-       if *templateDir != "" {
-               defaultpath := path
-               path = pathpkg.Join(*templateDir, name)
-               if _, err := fs.Stat(path); err != nil {
-                       log.Print("readTemplate:", err)
-                       path = defaultpath
-               }
-       }
 
        // use underlying file system fs to read the template file
        // (cannot use template ParseFile functions directly)
index 23f712ab3e4f74090e3198fcb26ff5cae6cc4a74..da4fc63b5f8ba129219acfc41e2338128cc06762 100644 (file)
@@ -167,6 +167,9 @@ func main() {
        if *zipfile == "" {
                // use file system of underlying OS
                fs.Bind("/", OS(*goroot), "/", bindReplace)
+               if *templateDir != "" {
+                       fs.Bind("/lib/godoc", OS(*templateDir), "/", bindBefore)
+               }
        } else {
                // use file system specified via .zip file (path separator must be '/')
                rc, err := zip.OpenReader(*zipfile)