From 6a33d518d67676fb7dc046b238e90004f693433a Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Sat, 23 Jun 2018 10:08:54 +0300 Subject: [PATCH] :construction_worker: Fix issues found by go-critic linter Also fixes broken test --- golyrics.go | 6 +++--- golyrics_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/golyrics.go b/golyrics.go index a26f657..e4d6d03 100644 --- a/golyrics.go +++ b/golyrics.go @@ -44,7 +44,7 @@ func breakToNewLine(HTML string) string { } func stripeHTMLTags(HTML string) string { - regex, _ := regexp.Compile("<[^>]+>") + regex := regexp.MustCompile("<[^>]+>") return regex.ReplaceAllString(HTML, "") } @@ -78,7 +78,7 @@ func SearchTrack(query string) ([]Track, error) { suggestions := []Track{} jsonparser.ArrayEach(data, func(value []byte, _ jsonparser.ValueType, offset int, _ error) { - title := string(value[:]) + title := string(value) trackParts := strings.SplitN(title, ":", 2) if len(trackParts) < 2 { return @@ -95,6 +95,6 @@ func SearchTrack(query string) ([]Track, error) { // SearchTrackByArtistAndName searches for tracks // using artist and name of the track. -func SearchTrackByArtistAndName(artist string, name string) ([]Track, error) { +func SearchTrackByArtistAndName(artist, name string) ([]Track, error) { return SearchTrack(artist + ":" + name) } diff --git a/golyrics_test.go b/golyrics_test.go index 16a489d..9ed33c2 100644 --- a/golyrics_test.go +++ b/golyrics_test.go @@ -247,7 +247,7 @@ func TestTrack_FetchLyrics(t *testing.T) { fields: fields{ Artist: "Sandra_Boynton", Name: "The_Shortest_Song_In_The_Universe", - Lyrics: "The shortest song in the universe\nReally isn't much fun\nIt only has one puny verse\n. . . and then it's done!\n", + Lyrics: "The shortest song in the universe\nReally isn't much fun\nIt only has one puny verse\n... And then it's done!\n", }, }, }