mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
960 B
960 B
name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
| name | slug | sourceRef | category | subCategory | playUrl | variantHelpers | similarHelpers | position | signatures | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ChunkString | chunkstring | it/string.go#L130 | it | string |
|
|
0 |
|
Returns a sequence of chunks of length size from the input string. If the string length is not a multiple of size, the final chunk contains the remaining characters. Panics if size <= 0.
Examples:
// Even split
seq := it.ChunkString("123456", 2)
var out []string
for s := range seq { out = append(out, s) }
// out == []string{"12", "34", "56"}
// Remainder chunk
seq := it.ChunkString("1234567", 2)
var out []string
for s := range seq { out = append(out, s) }
// out == []string{"12", "34", "56", "7"}
// Empty and small inputs
seq1 := it.ChunkString("", 2)
seq2 := it.ChunkString("1", 2)
// seq1 yields ""
// seq2 yields "1"