-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accepting interface{} instead of []interface{} in BatchGetObjects #310
Comments
Makes sense. Will do. |
Btw, I also think that accepting empty/nil slice and appending to it found object might be more convenient. So that the final signature is the following:
That way package users won't have to iterate |
That way you won't be able to reuse a pre-allocated slice. |
you will be able, when truncating it to zero length. That way append won't allocate memory, but reuse underlying slice's capacity. |
ah, you literally meant append. That won't work due to race condition. We can only set at index without race, not append. |
Version: v3.0+
What we have now:
BatchGetObjects(policy *BatchPolicy, keys []*Key, objects []interface{}) (found []bool, err error)
So, to get objects into
[]myStruct
one have to first get them into[]interface{}
, then convert eachinterface{}
intomyStruct
.I suggest:
BatchGetObjects(policy *BatchPolicy, keys []*Key, objects interface{}) (found []bool, err error)
This way one can pass
[]myStruct
directly intoBatchGetObjects
. InsideBatchGetObjects
reflect
package can be used to check whether a slice type of appropriate length is passed.As this is a breaking change, I suppose it may be implemented v4.0+.
The text was updated successfully, but these errors were encountered: