implement sort.Interface for core.Feed
This commit is contained in:
@@ -92,6 +92,24 @@ func GofeedConvert(f *gofeed.Feed, title string) (*Feed, error) {
|
||||
return new, nil
|
||||
}
|
||||
|
||||
// Implement sort.Interface for Feed
|
||||
|
||||
// Len returns the length of Items.
|
||||
func (f *Feed) Len() int {
|
||||
return len(f.Items)
|
||||
}
|
||||
|
||||
// Less compares Published of Items[i], Items[k] and returns true if Items[i] is
|
||||
// before Items[j].
|
||||
func (f *Feed) Less(i, j int) {
|
||||
return f.Items[i].Published.Before(f.Items[j].Published)
|
||||
}
|
||||
|
||||
// Swap swaps Items[i] and Items[j].
|
||||
func (f *Feed) Swap(i, j int) {
|
||||
f.Items[i], f.Items[j] = f.Items[j], f.Items[i]
|
||||
}
|
||||
|
||||
// Lock locks both feed and page mutexes.
|
||||
func (j *jsonData) Lock() {
|
||||
j.feedsMu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user