From 56a047cddef5ebdfb1bc52ac8517dd8663cca111 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Thu, 14 Jul 2022 18:38:37 +0200 Subject: [PATCH] Fixed issues found by staticcheck. (#227) --- util/client.go | 8 ++++---- util/file.go | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/util/client.go b/util/client.go index b0e5c59..d6cd150 100644 --- a/util/client.go +++ b/util/client.go @@ -41,7 +41,7 @@ type LimitingClient struct { // Do implements the respective method of the Client interface. func (lc *LoggingClient) Do(req *http.Request) (*http.Response, error) { log.Printf("[DO]: %s\n", req.URL.String()) - return lc.Do(req) + return lc.Client.Do(req) } // Get implements the respective method of the Client interface. @@ -53,19 +53,19 @@ func (lc *LoggingClient) Get(url string) (*http.Response, error) { // Head implements the respective method of the Client interface. func (lc *LoggingClient) Head(url string) (*http.Response, error) { log.Printf("[HEAD]: %s\n", url) - return lc.Head(url) + return lc.Client.Head(url) } // Post implements the respective method of the Client interface. func (lc *LoggingClient) Post(url, contentType string, body io.Reader) (*http.Response, error) { log.Printf("[POST]: %s\n", url) - return lc.Post(url, contentType, body) + return lc.Client.Post(url, contentType, body) } // PostForm implements the respective method of the Client interface. func (lc *LoggingClient) PostForm(url string, data url.Values) (*http.Response, error) { log.Printf("[POST FORM]: %s\n", url) - return lc.PostForm(url, data) + return lc.Client.PostForm(url, data) } // Do implements the respective method of the Client interface. diff --git a/util/file.go b/util/file.go index 68b91aa..3fd1f98 100644 --- a/util/file.go +++ b/util/file.go @@ -29,9 +29,7 @@ var invalidRune = regexp.MustCompile(`[^+\-a-z0-9]+`) // invalid runes + `_` // specifies valid runes as 'a' to 'z', '0' to '9' and '+', '-', '_'. func CleanFileName(s string) string { s = strings.ToLower(s) - if strings.HasSuffix(s, ".json") { - s = s[:len(s)-len(".json")] - } + s = strings.TrimSuffix(s, ".json") return invalidRune.ReplaceAllString(s, "_") + ".json" }