8000 fix the bug reflect on zero Value by ninghejun · Pull Request #69 · thoas/go-funk · GitHub
[go: up one dir, main page]

Skip to content

fix the bug reflect on zero Value - #69

Merged
thoas merged 1 commit into
thoas:masterfrom
ninghejun:patch-1
Nov 24, 2019
Merged

thoas merged 1 commit into
thoas:masterfrom
ninghejun:patch-1

Conversation

@ninghejun
@ninghejun ninghejun commented Nov 21, 2019 •
Copy link
Copy Markdown
Contributor

fix the bug :reflect: call of reflect.Value.Type on zero Value

if the slice is nil, or len==0, will be panic.
the case:

type Foo struct{
	Bar[]int
}

func TestGoFunk(t *testing.T) {
	foo := []Foo{}
	bars := funk.Get(foo, "Bar") //panic !!
	fmt.Print(bars)
}

fix the bug :reflect: call of reflect.Value.Type on zero Value

if the slice is nil, or len==0, will be panic.
the case:

type Foo struct{
	Bar[]int
}

func TestGoFunk(t *testing.T) {
	Log.InitLog()
	foo := []Foo{}
	bars := funk.Get(foo, "Bar") //panic !!
	fmt.Print(bars)
}
@thoas
thoas merged commit 3108806 into thoas:master Nov 24, 2019
@thoas
thoas commented Nov 24, 2019
Copy link
Copy Markdown
Owner

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants

2BF3
0