From 87bc3827475a2e7982aa206937c9834c3e6415fe Mon Sep 17 00:00:00 2001 From: nxshock Date: Sun, 27 Nov 2022 14:33:56 +0500 Subject: [PATCH] Resolve linter issues --- handlers.go | 2 +- parser.go | 17 +++++++++++++++-- streamer.go | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/handlers.go b/handlers.go index a220010..c77de9e 100644 --- a/handlers.go +++ b/handlers.go @@ -86,7 +86,7 @@ func handleGetM3u(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "audio/x-mpegurl") w.Header().Set("Accept-Ranges", "none") - w.Write(b) + _, _ = w.Write(b) } func handleStream(w http.ResponseWriter, r *http.Request) { diff --git a/parser.go b/parser.go index ab3395c..928a9f5 100644 --- a/parser.go +++ b/parser.go @@ -3,6 +3,7 @@ package main import ( "bytes" "fmt" + "net/http" "net/url" "strconv" "strings" @@ -40,7 +41,13 @@ func UpdateGenres() error { func updateGenreList() ([]Genre, error) { url := "https://promodj.com/music" - doc, err := goquery.NewDocument(url) + resp, err := http.Get(url) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + doc, err := goquery.NewDocumentFromReader(resp.Body) if err != nil { return nil, err } @@ -54,7 +61,13 @@ func updateGenreList() ([]Genre, error) { } func parsePage(url string, resultsChan chan TrackInfo) { - doc, err := goquery.NewDocument(url) + resp, err := http.Get(url) + if err != nil { + return + } + defer resp.Body.Close() + + doc, err := goquery.NewDocumentFromReader(resp.Body) if err != nil { return } diff --git a/streamer.go b/streamer.go index 861a269..a754d5c 100644 --- a/streamer.go +++ b/streamer.go @@ -57,7 +57,7 @@ func encode(url string, w io.Writer) error { buf := buffer.New(int64(config.BufferSize) * 1024 * 1024) _, err = nio.Copy(w, out, buf) if err != nil { - cmd.Process.Kill() + _ = cmd.Process.Kill() } return nil