diff --git a/lib/godoc/dirlist.html b/lib/godoc/dirlist.html index c1f24d758da..b35da55d8d0 100644 --- a/lib/godoc/dirlist.html +++ b/lib/godoc/dirlist.html @@ -18,7 +18,7 @@ {.repeated section @} - {Name|html} + {Name|html}{@|dir/} {Size|html} diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go index 09b110cabaa..b590cd29712 100644 --- a/src/cmd/godoc/godoc.go +++ b/src/cmd/godoc/godoc.go @@ -694,6 +694,14 @@ func timeFmt(w io.Writer, x interface{}, format string) { } +// Template formatter for "dir/" format. +func dirslashFmt(w io.Writer, x interface{}, format string) { + if x.(*os.Dir).IsDirectory() { + w.Write([]byte{'/'}) + } +} + + var fmap = template.FormatterMap{ "": textFmt, "html": htmlFmt, @@ -705,6 +713,7 @@ var fmap = template.FormatterMap{ "infoSnippet": infoSnippetFmt, "padding": paddingFmt, "time": timeFmt, + "dir/": dirslashFmt, } @@ -802,6 +811,13 @@ func serveHTMLDoc(c *http.Conn, r *http.Request, path string) { return } + // if it begins with "