aboutsummaryrefslogtreecommitdiffstats
path: root/util.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-01-20 17:56:39 -0500
committerSam Anthony <sam@samanthony.xyz>2024-01-20 17:56:39 -0500
commit3aaae870ba76d8f0907b10a61d829ad353936306 (patch)
tree8be8cb950d0aa8039cd977c72e2f9438cae4a1e8 /util.go
parentdb183cf7570e0f4e448ab5ced0ae41969261a815 (diff)
downloadvolute-3aaae870ba76d8f0907b10a61d829ad353936306.zip
flatten source directory structure by removing modules
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:]...)
+}