mirror of
https://github.com/samber/lo.git
synced 2026-04-22 15:37:14 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
2.2 KiB
2.2 KiB
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| UnzipByErrX | unzipbyerrx | tuples.go#L1024 | core | tuple |
|
https://go.dev/play/p/G2pyXQa1SUD |
|
|
41 |
Transforms each input element into a tuple and splits results into parallel slices. The iteratee can return an error to stop iteration immediately. Variants support arities from 2 to 9.
Variants: UnzipByErr2..UnzipByErr9
a, b, err := lo.UnzipByErr2([]string{"hello", "error", "world"}, func(str string) (string, int, error) {
if str == "error" {
return "", 0, fmt.Errorf("error string not allowed")
}
return str, len(str), nil
})
// []string{}
// []int{}
// error string not allowed
On error, all result slices are nil and iteration stops immediately.