Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@sneko

Description

@sneko

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions