summaryrefslogtreecommitdiff
path: root/pkg/files.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/files.go')
-rw-r--r--pkg/files.go16
1 files changed, 4 insertions, 12 deletions
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
}