You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Respect errors in cb function in ArrayEach and EachKey #53
We have no options to stop iterate over data even if our function extractBars will return an error.
I think there are two possible ways of fixing this issue.
1. If we don't care about backward compatibility
Just change cb signature to cb func(value []byte, dataType ValueType, offset int, err error) error.
2. If we respect backward compatibility
Then we could add counterpart for both there functions and name these like IterArray, IterKeys or something like this.
P.S.: In both cases I could contribute with PR.
Reacted by Timon Wong, Darlin Alberto, sthetz and Egor Shulakov
Activity
buger commentedon Jul 12, 2016
In our case probably better return
trueorfalse.This is about easier API vs some speed improvement for some (rare?) cases. Not sure if it will be useful for most of the users.
lorehov commentedon Jul 12, 2016
I agree, this is more generic as we could decide to stop iteration even if no error occurs, just because we got enough data.
Meanwhile I'm using following workaround:
So given all this do we need
IterArray/IterKeyswith callback signaturecb func(value []byte, dataType ValueType, offset int, err error) bool?kdar commentedon Jul 9, 2017
Ran into this issue today. I find it weird that it doesn't follow the same style of ObjectEach in this regard.
v1.4.0: ArrayEachErr, Escape/SetString, wildcards, JSONPath, GetArray…