From 788c54b153bc3cb88479758210a458f7489923c1 Mon Sep 17 00:00:00 2001 From: Baraa Al-Masri Date: Mon, 22 Apr 2024 10:21:39 +0300 Subject: [PATCH] chore(youtube): limit max number of suggestions --- services/youtube/youtube.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/youtube/youtube.go b/services/youtube/youtube.go index 525f2d7..804e5e1 100644 --- a/services/youtube/youtube.go +++ b/services/youtube/youtube.go @@ -60,7 +60,10 @@ func SearchSuggestions(query string) (sugesstions []string, err error) { panic(err) } - for _, res := range results[1].([]any) { + for i, res := range results[1].([]any) { + if i >= 9 { // max displayed suggestions is 10 + break + } sugesstions = append(sugesstions, res.(string)) }