improve documentation for PageEntries functions
This commit is contained in:
+6
-1
@@ -148,15 +148,20 @@ type PageEntries struct {
|
|||||||
Entries []*PageEntry
|
Entries []*PageEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement sort.Interface
|
// Implement sort.Interface for PageEntries
|
||||||
|
|
||||||
|
// Len returns the length of Entries
|
||||||
func (e *PageEntries) Len() int {
|
func (e *PageEntries) Len() int {
|
||||||
return len(e.Entries)
|
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 {
|
func (e *PageEntries) Less(i, j int) bool {
|
||||||
return e.Entries[i].Published.After(e.Entries[j].Published)
|
return e.Entries[i].Published.After(e.Entries[j].Published)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Swap swaps Entries[i] and Entries[j]
|
||||||
func (e *PageEntries) Swap(i, j int) {
|
func (e *PageEntries) Swap(i, j int) {
|
||||||
e.Entries[i], e.Entries[j] = e.Entries[j], e.Entries[i]
|
e.Entries[i], e.Entries[j] = e.Entries[j], e.Entries[i]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user