aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2022-06-05 18:01:39 +0100
committerGrégoire Duchêne <gduchene@awhk.org>2022-06-05 18:01:39 +0100
commit0315338ef5c5fadd739088684323b82535fc904b (patch)
treec7febbf73ef122cd7c46f3e6e81c09432c8d4987 /util.go
parent326a741c1298959e5d6e5eb1a6b2225ef9151063 (diff)
Add Listen, Must, PipeListener, and T
Diffstat (limited to 'util.go')
-rw-r--r--util.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..34cf28b
--- /dev/null
+++ b/util.go
@@ -0,0 +1,9 @@
+package core
+
+// Must panics if err is not nil. It returns val otherwise.
+func Must[T any](val T, err error) T {
+ if err != nil {
+ panic(err)
+ }
+ return val
+}