Подготовить HY2XS к production-сборке

This commit is contained in:
2026-04-25 23:13:12 +05:00
commit 84a4e94567
277 changed files with 26513 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
package util
func SplitMap[T any](inputMap map[string]T, chunkSize int) []map[string]T {
length := len(inputMap)
quantity := (length + chunkSize - 1) / chunkSize
segments := make([]map[string]T, 0, quantity)
var groupIndex int
currentGroup := make(map[string]T)
for key, value := range inputMap {
currentGroup[key] = value
if len(currentGroup) == chunkSize || groupIndex+1 == quantity {
// When the current group is full or the last group is reached, add the mapping to the result slice
segments = append(segments, currentGroup)
currentGroup = make(map[string]T) // Initialize a new mapping
groupIndex++
}
}
return segments
}