Cron_Admin/app/utils/helper/convert.go

20 lines
517 B
Go

package helper
import "github.com/duke-git/lancet/v2/slice"
func SliceConvertSlice[O int | int32 | int64 | int8, T int | int32 | int64 | int8](inputSlice []T) []O {
output := slice.Map(inputSlice, func(_ int, item T) O {
return O(item)
})
return output
}
// MergeInt64Slices 合并两个 []O 切片为一个新的 []O 切片
func MergeInt64Slices[O int | int32 | int64 | int8](a, b []O) []O {
length := len(a) + len(b)
merged := make([]O, length)
copy(merged, a)
copy(merged[len(a):], b)
return merged
}