From 39f980b7a5085505bcb4afde8f34626553db0eb5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 28 Jan 2018 08:44:35 +0100 Subject: cleanup --- urban.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'urban.go') diff --git a/urban.go b/urban.go index aa13606..6a1fb47 100644 --- a/urban.go +++ b/urban.go @@ -31,13 +31,13 @@ type Entry struct { Word string `json:"word"` } -var noMatches = errors.New("no matches") +var ErrNoMatches = errors.New("no matches") -type ByRatio []Entry +type byRatio []Entry -func (l ByRatio) Len() int { return len(l) } -func (l ByRatio) Swap(i, j int) { l[i], l[j] = l[j], l[i] } -func (l ByRatio) Less(i, j int) bool { +func (l byRatio) Len() int { return len(l) } +func (l byRatio) Swap(i, j int) { l[i], l[j] = l[j], l[i] } +func (l byRatio) Less(i, j int) bool { a := float64(l[i].ThumbsUp) / float64(l[i].ThumbsDown) b := float64(l[j].ThumbsUp) / float64(l[j].ThumbsDown) return a < b @@ -65,8 +65,8 @@ func QueryTop(q string) (Entry, error) { return Entry{}, err } if len(a.List) > 0 { - sort.Sort(sort.Reverse(ByRatio(a.List))) + sort.Sort(sort.Reverse(byRatio(a.List))) return a.List[0], nil } - return Entry{}, noMatches + return Entry{}, ErrNoMatches } -- cgit v1.2.3