diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-08-11 09:54:46 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-09-23 10:02:55 +0300 |
commit | 80736c54d3a24702733c6e8227e56b5067742802 (patch) | |
tree | 65fc3663578b8cc18419caec5459b862600358d1 | |
parent | 9c4937daf01220a9fd99d67dd5b5d5d9df1e9954 (diff) |
linguist: Ignore error in deferred close of zlib writer
We already check the error when we manually close the zlib writer, but
don't in the deferred call. This is fine though at it won't do anything
in the happy path as the writer was closed already, and we already got
an error in the unhappy path.
Explicitly ignore the error to make our linters happy.
-rw-r--r-- | .golangci.yml | 1 | ||||
-rw-r--r-- | internal/gitaly/linguist/language_stats.go | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/.golangci.yml b/.golangci.yml index a80d3f5fc..a8ebf5f14 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -53,7 +53,6 @@ linters-settings: # eventually fix. exclude-functions: # Close - - (*compress/zlib.Writer).Close - (*database/sql.DB).Close - (*database/sql.Rows).Close - (*github.com/hashicorp/yamux.Session).Close diff --git a/internal/gitaly/linguist/language_stats.go b/internal/gitaly/linguist/language_stats.go index e65a90c9a..cefa3b644 100644 --- a/internal/gitaly/linguist/language_stats.go +++ b/internal/gitaly/linguist/language_stats.go @@ -135,7 +135,10 @@ func (c *languageStats) save(repo *localrepo.Repo, commitID string) error { }() w := zlib.NewWriter(file) - defer w.Close() + defer func() { + // We already check the error further down. + _ = w.Close() + }() if err = json.NewEncoder(w).Encode(c); err != nil { return fmt.Errorf("languageStats encode json: %w", err) |