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:
parent
5eb007dede
commit
d71d11fa93
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user