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:
Simon Ser 2019-06-14 15:56:11 +00:00 committed by Drew DeVault
parent 606f7b68d3
commit b0904bf2ae

View file

@ -118,6 +118,9 @@ func main() {
sort.Slice(articles, func(i, j int) bool {
return articles[i].Date.After(articles[j].Date)
})
if len(articles) < narticles {
narticles = len(articles)
}
articles = articles[:narticles]
err = tmpl.Execute(os.Stdout, struct{
Articles []*Article