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)
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)