From be915c8d3881dc50c0fe633e6bf170f7c513efbb Mon Sep 17 00:00:00 2001 From: Tom Neuber Date: Fri, 18 Apr 2025 15:06:11 +0200 Subject: [PATCH] fix: add linter exceptions for current code style --- internal/cmd/root.go | 2 ++ internal/logger/logger.go | 1 + pkg/grafana/client.go | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 4d5fb05..2d73971 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -52,9 +52,11 @@ func NewRootCommand(c *config.Config) *cobra.Command { } if c.JSONFormat { + //nolint:reassign // overwriting the default logger with the desired logger layout log.Logger = logger.JSONLoggerLayout(os.Stderr) c.Logger = logger.JSONLoggerLayout(os.Stdout) } else { + //nolint:reassign // overwriting the default logger with the desired logger layout log.Logger = logger.CliLoggerLayout(os.Stderr) c.Logger = logger.CliLoggerLayout(os.Stdout) } diff --git a/internal/logger/logger.go b/internal/logger/logger.go index fbcc944..b5ba12b 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -10,6 +10,7 @@ import ( ) func CliLoggerLayout(out io.Writer) zerolog.Logger { + //nolint:reassign // overwriting the default caller layout with the desired layout zerolog.CallerMarshalFunc = func(_ uintptr, file string, line int) string { return fmt.Sprintf("%s:%d", filepath.Base(file), line) } diff --git a/pkg/grafana/client.go b/pkg/grafana/client.go index ee4ab86..760b7c9 100644 --- a/pkg/grafana/client.go +++ b/pkg/grafana/client.go @@ -109,9 +109,9 @@ func (c *Client) do(req *http.Request, v any) (*Response, error) { return resp, err } defer httpResp.Body.Close() + defer resp.Body.Close() body, err := io.ReadAll(resp.Body) - resp.Body.Close() if err != nil { return resp, err }