From 060ab92d295ba9dd8e34115c92557d5eff5896ff Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 10 Jan 2016 09:47:26 -0700 Subject: [PATCH] Reorder a few things The docs link to this structure and all its methods related to the browse template; keeping them together makes it possible to link to the whole block of code that is relevant. --- middleware/browse/browse.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/middleware/browse/browse.go b/middleware/browse/browse.go index 75a5b32c..94741d9b 100644 --- a/middleware/browse/browse.go +++ b/middleware/browse/browse.go @@ -106,6 +106,17 @@ type FileInfo struct { Mode os.FileMode } +// HumanSize returns the size of the file as a human-readable string +// in IEC format (i.e. power of 2 or base 1024). +func (fi FileInfo) HumanSize() string { + return humanize.IBytes(uint64(fi.Size)) +} + +// HumanModTime returns the modified time of the file as a human-readable string. +func (fi FileInfo) HumanModTime(format string) string { + return fi.ModTime.Format(format) +} + // Implement sorting for Listing type byName Listing type bySize Listing @@ -161,17 +172,6 @@ func (l Listing) applySort() { } } -// HumanSize returns the size of the file as a human-readable string -// in IEC format (i.e. power of 2 or base 1024). -func (fi FileInfo) HumanSize() string { - return humanize.IBytes(uint64(fi.Size)) -} - -// HumanModTime returns the modified time of the file as a human-readable string. -func (fi FileInfo) HumanModTime(format string) string { - return fi.ModTime.Format(format) -} - func directoryListing(files []os.FileInfo, r *http.Request, canGoUp bool, root string, ignoreIndexes bool, vars interface{}) (Listing, error) { var fileinfos []FileInfo var dirCount, fileCount int