aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-01-22 17:35:45 -0500
committerSam Anthony <sam@samanthony.xyz>2024-01-22 17:35:45 -0500
commit2a14395beedc4b3cef74dd7d8b44f14bb8a7ac79 (patch)
tree4216df7bc1ae2404c3fef879987eab50bbe89260 /util.go
parent4f6384f449b50a95255837b1fc394b4ebe14caaf (diff)
parent9ad538983290fbd62da7f8d6db5a6dfe123a25c3 (diff)
downloadvolute-2a14395beedc4b3cef74dd7d8b44f14bb8a7ac79.zip
merge backend refactoring from main
Diffstat (limited to 'util.go')
-rw-r--r--util.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..22f9cb2
--- /dev/null
+++ b/util.go
@@ -0,0 +1,21 @@
+package main
+
+import (
+ "fmt"
+ "os"
+)
+
+func Check(err error) {
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+}
+
+func Insert[T any](slice []T, elem T, i int) []T {
+ return append(slice[:i], append([]T{elem}, slice[i:]...)...)
+}
+
+func Remove[T any](slice []T, i int) []T {
+ return append(slice[:i], slice[i+1:]...)
+}