Skip to content
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

Panic with empty array during Get(...) call #68

Closed
sneko opened this issue Nov 21, 2019 · 2 comments
Closed

Panic with empty array during Get(...) call #68

sneko opened this issue Nov 21, 2019 · 2 comments

Comments

@sneko
Copy link

sneko commented Nov 21, 2019

Hi,

When using funk.Get(make([]*Xxxxx, 0), "Aaaa.Bbbbb") I get this panic:

panic: reflect: call of reflect.Value.Type on zero Value
goroutine 1 [running]:
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x9f34c0)
	/usr/local/go/src/reflect/value.go:1743 +0x16c
github.com/thoas/go-funk.get(0xa0e300, 0xc000474cc0, 0x197, 0xb66d75, 0xb, 0x197, 0x2, 0xae7d00)
	/home/aaaaaaa/vendor/github.com/thoas/go-funk/retrieve.go:46 +0x289
github.com/thoas/go-funk.get(0x9f34c0, 0xc000474cc0, 0x16, 0xb66d75, 0xe, 0xa37000, 0xb8d968, 0x13)
	/home/aaaaaaa/vendor/github.com/thoas/go-funk/retrieve.go:69 +0x4b2
github.com/thoas/go-funk.Get(0x9f34c0, 0xc000474cc0, 0xb66d75, 0xe, 0xc0002d1700, 0x76e4da)
	/home/aaaaaaa/vendor/github.com/thoas/go-funk/retrieve.go:10 +0xbe

It's related to:
https://github.com/thoas/go-funk/blob/master/retrieve.go#L45-L48

I don't understand exactly why this is happening. I can for sure make a statement my array is not empty before using funk.Get, but maybe funk should return me an empty array?

Thanks,

@ninghejun
Copy link
Contributor

#69

wait to merge

@thoas thoas closed this as completed Nov 24, 2019
@thoas
Copy link
Owner

thoas commented Nov 24, 2019

Fixed thanks to @ninghejun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants