From dc48b53d1c2b659b2ff41a6537853a814e557a81 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Thu, 3 Apr 2025 11:19:44 +0200 Subject: [PATCH] fix(ci): comply with linter --- cmd/gogitlabber/gitlab.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/gogitlabber/gitlab.go b/cmd/gogitlabber/gitlab.go index ba9b495..27bf6ae 100644 --- a/cmd/gogitlabber/gitlab.go +++ b/cmd/gogitlabber/gitlab.go @@ -17,10 +17,10 @@ func fetchRepositoriesGitlab() ([]Repository, error) { // configure archived options var archived string - switch { - case includeArchived == "excluded": + switch includeArchived { + case "excluded": archived = "&archived=false" - case includeArchived == "only": + case "only": archived = "&archived=true" default: archived = "" @@ -32,7 +32,7 @@ func fetchRepositoriesGitlab() ([]Repository, error) { logger.Print("HTTP: Creating API request", nil) req, err := http.NewRequest("GET", url, nil) if err != nil { - return nil, fmt.Errorf("ERROR: creating request: %v\n", err) + return nil, fmt.Errorf("ERROR: creating request: %v", err) } logger.Print("HTTP: Adding PRIVATE-TOKEN header to API request", nil) @@ -42,12 +42,16 @@ func fetchRepositoriesGitlab() ([]Repository, error) { client := &http.Client{} resp, err := client.Do(req) if err != nil { - return nil, fmt.Errorf("ERROR: making request: %v\n", err) + return nil, fmt.Errorf("ERROR: making request: %v", err) } - defer resp.Body.Close() + defer func() { + if err := resp.Body.Close(); err != nil { + logger.Fatal("HTTP: Error closing response body", err) + } + }() if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("ERROR: API request failed with status: %d\n", resp.StatusCode) + return nil, fmt.Errorf("ERROR: API request failed with status: %d", resp.StatusCode) } logger.Print("HTTP: Decoding JSON response", nil)