const PackSizeLimit = 5 * 1024 * 1024 // [a b c] -> [[a, b], [c]] // where (len(a)+len(b) < MAX) and (len(c) < MAX), // where (len(a) < MAX) and (len(b) < MAX) and (len(c) < MAX), // but (len(a) + len(b) + len(c)) > MAX func splitForJoin(chunks [][]byte, lim int) [][][]byte { var result [][][]byte for len(chunks) > 0 { for i, v := range chunks { if size+len(v) > PackSizeLimit { chunks = chunks[i:] break } } // TODO } return result }