summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-01-28 08:44:35 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-01-28 08:44:35 +0100
commit39f980b7a5085505bcb4afde8f34626553db0eb5 (patch)
tree2fa55928dbfc537bd51d457a477ac74c97813db3
parent5e8a999bce349701001c0e987792e78a7296e87f (diff)
cleanup
-rw-r--r--urban.go14
1 files changed, 7 insertions, 7 deletions
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
}