Fix panic when too few feeds are retrieved
panic: runtime error: slice bounds out of range goroutine 1 [running]: main.main() /home/simon/src/openring/openring.go:121 +0xef4 exit status 2
This commit is contained in:
parent
606f7b68d3
commit
b0904bf2ae
1 changed files with 3 additions and 0 deletions
|
@ -118,6 +118,9 @@ func main() {
|
||||||
sort.Slice(articles, func(i, j int) bool {
|
sort.Slice(articles, func(i, j int) bool {
|
||||||
return articles[i].Date.After(articles[j].Date)
|
return articles[i].Date.After(articles[j].Date)
|
||||||
})
|
})
|
||||||
|
if len(articles) < narticles {
|
||||||
|
narticles = len(articles)
|
||||||
|
}
|
||||||
articles = articles[:narticles]
|
articles = articles[:narticles]
|
||||||
err = tmpl.Execute(os.Stdout, struct{
|
err = tmpl.Execute(os.Stdout, struct{
|
||||||
Articles []*Article
|
Articles []*Article
|
||||||
|
|
Loading…
Reference in a new issue