s1s1ty/goin

failed to evaluate array

Closed this issue · 8 comments

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)
}

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.

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

Reflect is costly...

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.

hmmm..ok send PR.

Update implementation. This update reduce 812 ns / op to 122 ns / op

Thanks

Fixed by pr: #3