aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/util/closer.go
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:44 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:44 +0800
commitdd84b9d64fb98746a230cd24233ff50a562c39c9 (patch)
treeb583261ef00b3afe72ec4d6dacb31e57779a6faf /cli/internal/util/closer.go
parent0b46fcd72ac34382387b2bcf9095233efbcc52f4 (diff)
downloadHydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.tar.gz
HydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.zip
Diffstat (limited to 'cli/internal/util/closer.go')
-rw-r--r--cli/internal/util/closer.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/cli/internal/util/closer.go b/cli/internal/util/closer.go
new file mode 100644
index 0000000..996760b
--- /dev/null
+++ b/cli/internal/util/closer.go
@@ -0,0 +1,15 @@
+package util
+
+// CloseAndIgnoreError is a utility to tell our linter that we explicitly deem it okay
+// to not check a particular error on closing of a resource.
+//
+// We use `errcheck` as a linter, which is super-opinionated about checking errors,
+// even in places where we don't necessarily care to check the error.
+//
+// `golangci-lint` has a default ignore list for this lint problem (EXC0001) which
+// can be used to sidestep this problem but it's possibly a little too-heavy-handed
+// in exclusion. At the expense of discoverability, this utility function forces
+// opt-in to ignoring errors on closing of things that can be `Close`d.
+func CloseAndIgnoreError(closer interface{ Close() error }) {
+ _ = closer.Close()
+}