From b0904bf2aec676a04ca94e6d581e0a6cdf4861ef Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 14 Jun 2019 15:56:11 +0000 Subject: [PATCH] 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 --- openring.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openring.go b/openring.go index 9684672..1a8c79f 100644 --- a/openring.go +++ b/openring.go @@ -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