From 4a254746de7246ddf8ac131f734f224d49e927b7 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sun, 2 Jun 2024 01:17:36 +0200 Subject: chore(gonf): removed opinionated static checkers --- pkg/files.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'pkg/files.go') diff --git a/pkg/files.go b/pkg/files.go index 2fe0f6e..b9e7e5c 100644 --- a/pkg/files.go +++ b/pkg/files.go @@ -139,16 +139,12 @@ func resolveFiles() (status Status) { return } -func sha256sumOfFile(filename string) (hash []byte, err error) { +func sha256sumOfFile(filename string) ([]byte, error) { f, err := os.Open(filename) if err != nil { return nil, err } - defer func() { - if e := f.Close(); err == nil { - err = e - } - }() + defer f.Close() h := sha256.New() if _, err := io.Copy(h, f); err != nil { return nil, err @@ -156,16 +152,12 @@ func sha256sumOfFile(filename string) (hash []byte, err error) { return h.Sum(nil), nil } -func writeFile(filename string, contents []byte) (err error) { +func writeFile(filename string, contents []byte) error { f, err := os.Create(filename) if err != nil { return err } - defer func() { - if e := f.Close(); err == nil { - err = e - } - }() + defer f.Close() _, err = f.Write(contents) return err } -- cgit v1.2.3