diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-01-22 17:35:45 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-01-22 17:35:45 -0500 |
| commit | 2a14395beedc4b3cef74dd7d8b44f14bb8a7ac79 (patch) | |
| tree | 4216df7bc1ae2404c3fef879987eab50bbe89260 /util.go | |
| parent | 4f6384f449b50a95255837b1fc394b4ebe14caaf (diff) | |
| parent | 9ad538983290fbd62da7f8d6db5a6dfe123a25c3 (diff) | |
| download | volute-2a14395beedc4b3cef74dd7d8b44f14bb8a7ac79.zip | |
merge backend refactoring from main
Diffstat (limited to 'util.go')
| -rw-r--r-- | util.go | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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:]...) +} |