failed to evaluate array
Closed this issue · 8 comments
mirshahriar commented
You have consider only slice. Following test fails
ar2 := [5]int{500, 100, 10, 20, 80}
test2 := In(ar2, 800, "int")
if test2 != false {
t.Errorf("Test Failed: %v sequence and %v key inputted, %v expected, received: %v", ar2, 800, false, test2)
}
s1s1ty commented
I can consider this the new feature of my package. Thanks a lot for your suggestion 👍 . You can also send PR. It will be gladly appreciated.
mirshahriar commented
I have implement this in my own way. You can take a look. If you wish I can send pr.
https://github.com/aerokite/goin
s1s1ty commented
Reflect is costly...
mirshahriar commented
Yes. It is costly if you use this method frequently.
But when user calls In(ar interface{}, value interface{}, typ string)
, he may pass array too. In that case, seq, ok := ar.([]int)
will not work.
s1s1ty commented
hmmm..ok send PR.
mirshahriar commented
Update implementation. This update reduce 812 ns / op
to 122 ns / op
s1s1ty commented
Thanks
mirshahriar commented
Fixed by pr: #3