From e053e0e05ecd884067125627f0006d1b6e19226e Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 8 Jul 2019 13:20:17 -0500 Subject: first pass of corrections for golangci-lint Signed-off-by: baude --- pkg/errorhandling/errorhandling.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pkg/errorhandling/errorhandling.go (limited to 'pkg/errorhandling') diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go new file mode 100644 index 000000000..970d47636 --- /dev/null +++ b/pkg/errorhandling/errorhandling.go @@ -0,0 +1,23 @@ +package errorhandling + +import ( + "os" + + "github.com/sirupsen/logrus" +) + +// SyncQuiet syncs a file and logs any error. Should only be used within +// a defer. +func SyncQuiet(f *os.File) { + if err := f.Sync(); err != nil { + logrus.Errorf("unable to sync file %s: %q", f.Name(), err) + } +} + +// CloseQuiet closes a file and logs any error. Should only be used within +// a defer. +func CloseQuiet(f *os.File) { + if err := f.Close(); err != nil { + logrus.Errorf("unable to close file %s: %q", f.Name(), err) + } +} -- cgit v1.2.3-54-g00ecf