From 5c735b4ce00b956b4dde3b52acc69ac49c12086f Mon Sep 17 00:00:00 2001 From: nytpu Date: Wed, 17 Mar 2021 09:15:26 -0600 Subject: [PATCH] improve documentation for PageEntries functions --- core/structs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/structs.go b/core/structs.go index 6595100..e5a3ab5 100644 --- a/core/structs.go +++ b/core/structs.go @@ -148,15 +148,20 @@ type PageEntries struct { Entries []*PageEntry } -// Implement sort.Interface +// Implement sort.Interface for PageEntries + +// Len returns the length of Entries func (e *PageEntries) Len() int { return len(e.Entries) } +// Less compares the Published if Entries[i], Entries[j] and returns true if +// Entries[i] is /after/ Entries[j] (for reverse chronological sorting) func (e *PageEntries) Less(i, j int) bool { return e.Entries[i].Published.After(e.Entries[j].Published) } +// Swap swaps Entries[i] and Entries[j] func (e *PageEntries) Swap(i, j int) { e.Entries[i], e.Entries[j] = e.Entries[j], e.Entries[i] }