diff options
| author | nytpu <alex@nytpu.com> | 2021-03-17 09:15:26 -0600 |
|---|---|---|
| committer | nytpu <alex@nytpu.com> | 2021-03-17 09:16:19 -0600 |
| commit | 5c735b4ce00b956b4dde3b52acc69ac49c12086f (patch) | |
| tree | 0135f5a94b2f77b178bf07ae794b7d8f9345d9dc /core/structs.go | |
| parent | 521b1620077b184de65a501c7e7623f7edc79589 (diff) | |
improve documentation for PageEntries functions
Diffstat (limited to 'core/structs.go')
| -rw-r--r-- | core/structs.go | 7 |
1 files changed, 6 insertions, 1 deletions
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] } |
