node build fixed

This commit is contained in:
ra_ma
2025-09-20 14:08:38 +01:00
parent c6ebbe069d
commit 3d298fa434
1516 changed files with 535727 additions and 2 deletions

View File

@@ -0,0 +1,39 @@
package util
func SliceFrom[T any](slice []T, idx int) (ret []T, ok bool) {
if idx < 0 || idx >= len(slice) {
return []T{}, false
}
return slice[idx:], true
}
func SliceTo[T any](slice []T, idx int) (ret []T, ok bool) {
if idx < 0 || idx >= len(slice) {
return []T{}, false
}
return slice[:idx], true
}
func SliceStrFrom(slice string, idx int) (ret string, ok bool) {
if idx < 0 || idx >= len(slice) {
return "", false
}
return slice[idx:], true
}
func SliceStrTo(slice string, idx int) (ret string, ok bool) {
if idx < 0 || idx >= len(slice) {
return "", false
}
return slice[:idx], true
}
// Contains checks if a string slice contains a specific string
func Contains[T comparable](slice []T, item T) bool {
for _, s := range slice {
if s == item {
return true
}
}
return false
}