diff options
author | Tibor Vass <tvass@stumbleupon.com> | 2014-01-29 14:50:31 -0800 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2014-01-29 18:03:35 -0500 |
commit | 6dd2e9a49acde23dcf5e9701915f7e8ed692ce5a (patch) | |
tree | dbbc04239e25626868fad3e7faab656c26e3715a /hugolib/pageSort.go | |
parent | ff9f6e1b2a000a24e677b9a3fa8dfbdef11c404c (diff) |
gofmt all go code
Diffstat (limited to 'hugolib/pageSort.go')
-rw-r--r-- | hugolib/pageSort.go | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/hugolib/pageSort.go b/hugolib/pageSort.go index 6e0b9a12e..a50c464c8 100644 --- a/hugolib/pageSort.go +++ b/hugolib/pageSort.go @@ -14,7 +14,7 @@ package hugolib import ( - "sort" + "sort" ) /* @@ -23,27 +23,27 @@ import ( // A type to implement the sort interface for Pages type PageSorter struct { - pages Pages - by PageBy + pages Pages + by PageBy } // Closure used in the Sort.Less method. type PageBy func(p1, p2 *Page) bool func (by PageBy) Sort(pages Pages) { - ps := &PageSorter{ - pages: pages, - by: by, // The Sort method's receiver is the function (closure) that defines the sort order. - } - sort.Sort(ps) + ps := &PageSorter{ + pages: pages, + by: by, // The Sort method's receiver is the function (closure) that defines the sort order. + } + sort.Sort(ps) } var DefaultPageSort = func(p1, p2 *Page) bool { - if p1.Weight == p2.Weight { - return p1.Date.Unix() > p2.Date.Unix() - } else { - return p1.Weight < p2.Weight - } + if p1.Weight == p2.Weight { + return p1.Date.Unix() > p2.Date.Unix() + } else { + return p1.Weight < p2.Weight + } } func (ps *PageSorter) Len() int { return len(ps.pages) } @@ -53,44 +53,44 @@ func (ps *PageSorter) Swap(i, j int) { ps.pages[i], ps.pages[j] = ps.pages[j], p func (ps *PageSorter) Less(i, j int) bool { return ps.by(ps.pages[i], ps.pages[j]) } func (p Pages) Sort() { - PageBy(DefaultPageSort).Sort(p) + PageBy(DefaultPageSort).Sort(p) } func (p Pages) Limit(n int) Pages { - if len(p) < n { - return p[0:n] - } else { - return p - } + if len(p) < n { + return p[0:n] + } else { + return p + } } func (p Pages) ByWeight() Pages { - PageBy(DefaultPageSort).Sort(p) - return p + PageBy(DefaultPageSort).Sort(p) + return p } func (p Pages) ByDate() Pages { - date := func(p1, p2 *Page) bool { - return p1.Date.Unix() < p2.Date.Unix() - } + date := func(p1, p2 *Page) bool { + return p1.Date.Unix() < p2.Date.Unix() + } - PageBy(date).Sort(p) - return p + PageBy(date).Sort(p) + return p } func (p Pages) ByLength() Pages { - length := func(p1, p2 *Page) bool { - return len(p1.Content) < len(p2.Content) - } + length := func(p1, p2 *Page) bool { + return len(p1.Content) < len(p2.Content) + } - PageBy(length).Sort(p) - return p + PageBy(length).Sort(p) + return p } func (p Pages) Reverse() Pages { - for i, j := 0, len(p)-1; i < j; i, j = i+1, j-1 { - p[i], p[j] = p[j], p[i] - } + for i, j := 0, len(p)-1; i < j; i, j = i+1, j-1 { + p[i], p[j] = p[j], p[i] + } - return p + return p } |