diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-01-20 17:56:39 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-01-20 17:56:39 -0500 |
| commit | 3aaae870ba76d8f0907b10a61d829ad353936306 (patch) | |
| tree | 8be8cb950d0aa8039cd977c72e2f9438cae4a1e8 /util.go | |
| parent | db183cf7570e0f4e448ab5ced0ae41969261a815 (diff) | |
| download | volute-3aaae870ba76d8f0907b10a61d829ad353936306.zip | |
flatten source directory structure by removing modules
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:]...) +} |