Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Bug in value2Interface(): reflect.Bytes() called on Array value #1345

Closed
teejays opened this issue Jul 5, 2019 · 3 comments
Closed

Bug in value2Interface(): reflect.Bytes() called on Array value #1345

teejays opened this issue Jul 5, 2019 · 3 comments
Labels

Comments

@teejays
Copy link
Contributor

teejays commented Jul 5, 2019

I noticed that in value2Interface function in session_convert.go, we are using reflect.Value.Bytes() function when the fieldType is reflect.Array OR reflect.Slice. However, go's reflect.Value.Bytes() only works when the value is of type reflect.Slice, and panics otherwise.

I would propose that change the if condition from:

if (k == reflect.Array || k == reflect.Slice) && (...) {
    // logic
}

to

if (k == reflect.Slice) && (...) {
    // logic
}
@teejays teejays changed the title Issues with []byte type fields in structs Bug in value2Interface(): reflect.Bytes() called on Array value Jul 5, 2019
@lunny
Copy link
Member

lunny commented Jul 5, 2019

@teejays could you send a PR to fix that? Thanks.

@teejays
Copy link
Contributor Author

teejays commented Jul 5, 2019

Thanks @lunny, I created a PR: #1346

@lunny lunny added the kind/bug label Jul 5, 2019
@lunny
Copy link
Member

lunny commented Jul 5, 2019

Closed by #1346

@lunny lunny closed this as completed Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants