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

godoc: use int64 for timestamps

This fixes a crash seen when viewing a directory list.

Fixes #747.

R=gri
CC=golang-dev, rsc
https://golang.org/cl/1010042
This commit is contained in:
Christopher Wedgwood 2010-04-27 10:45:33 -07:00 committed by Robert Griesemer
parent bec40ba516
commit 23c064452c

View File

@ -783,8 +783,7 @@ func paddingFmt(w io.Writer, x interface{}, format string) {
// Template formatter for "time" format. // Template formatter for "time" format.
func timeFmt(w io.Writer, x interface{}, format string) { func timeFmt(w io.Writer, x interface{}, format string) {
// note: os.FileInfo.Mtime_ns is in uint64 in ns! template.HTMLEscape(w, []byte(time.SecondsToLocalTime(x.(int64)/1e9).String()))
template.HTMLEscape(w, []byte(time.SecondsToLocalTime(int64(x.(uint64)/1e9)).String()))
} }
@ -885,7 +884,7 @@ func servePage(c *http.Conn, title, subtitle, query string, content []byte) {
Title string Title string
Subtitle string Subtitle string
PkgRoots []string PkgRoots []string
Timestamp uint64 // int64 to be compatible with os.FileInfo.Mtime_ns Timestamp int64
Query string Query string
Version string Version string
Menu []byte Menu []byte
@ -897,7 +896,7 @@ func servePage(c *http.Conn, title, subtitle, query string, content []byte) {
Title: title, Title: title,
Subtitle: subtitle, Subtitle: subtitle,
PkgRoots: fsMap.PrefixList(), PkgRoots: fsMap.PrefixList(),
Timestamp: uint64(ts) * 1e9, // timestamp in ns Timestamp: ts * 1e9, // timestamp in ns
Query: query, Query: query,
Version: runtime.Version(), Version: runtime.Version(),
Menu: nil, Menu: nil,