mirror of
https://github.com/samber/lo.git
synced 2026-04-23 07:49:50 +08:00
760 B
760 B
name, slug, sourceRef, category, subCategory, playUrl, similarHelpers, position, signatures, variantHelpers
| name | slug | sourceRef | category | subCategory | playUrl | similarHelpers | position | signatures | variantHelpers | |||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Times | times | parallel/slice.go#L49 | parallel | slice |
|
20 |
|
|
Invokes the predicate count times, returning a slice of the results of each invocation. The predicate is called in parallel with the index as argument.
import (
"strconv"
lop "github.com/samber/lo/parallel"
)
nums := lop.Times(5, func(i int) string {
return strconv.Itoa(i)
})
// []string{"0", "1", "2", "3", "4"}
Great for generating data concurrently:
ids := lop.Times(10, func(i int) string {
return fmt.Sprintf("item-%d", i)
})