1
0
mirror of https://github.com/golang/go synced 2024-11-20 03:04:40 -07:00

cmd/godoc: use virtual filesystem to implement -templates flag

R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/5921045
This commit is contained in:
Andrew Gerrand 2012-03-28 09:13:48 +11:00
parent 5eb007dede
commit d71d11fa93
2 changed files with 3 additions and 8 deletions

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

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