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
Please answer these questions before submitting your issue. Thanks!
go version
go version go1.11 linux/amd64
yes. Does not happen with go1.9,but happen with go1.10
go env
ubuntu16.04 LTS
https://play.golang.org/p/Kw-Gm5YbkJw
nil
This only happen when innerType has a method named with capital letter.If method replace to f(),the panic won't happen.
innerType
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method goroutine 1 [running]: reflect.valueInterface(0x111880, 0x1f7264, 0x36, 0x1, 0x1, 0xe) /usr/local/go/src/reflect/value.go:989 +0x200 reflect.Value.Interface(0x111880, 0x1f7264, 0x36, 0x9, 0x152960, 0x111880) /usr/local/go/src/reflect/value.go:978 +0x40 encoding/json.indirect(0x110fe0, 0x1f7264, 0x1d9, 0x0, 0x416040, 0x5, 0x8, 0x18ec, 0x6c, 0x6c, ...) /usr/local/go/src/encoding/json/decode.go:486 +0x2c0 encoding/json.(*decodeState).object(0x44e060, 0x110fe0, 0x1f7264, 0x1d9, 0x44e078, 0x7b) /usr/local/go/src/encoding/json/decode.go:620 +0x60 encoding/json.(*decodeState).value(0x44e060, 0x110fe0, 0x1f7264, 0x1d9, 0x152960, 0x112dc0) /usr/local/go/src/encoding/json/decode.go:383 +0x60 encoding/json.(*decodeState).object(0x44e060, 0x111820, 0x1f7264, 0x16, 0x44e078, 0x7b) /usr/local/go/src/encoding/json/decode.go:781 +0x19c0 encoding/json.(*decodeState).value(0x44e060, 0x111820, 0x1f7264, 0x16, 0x44e078, 0x7d) /usr/local/go/src/encoding/json/decode.go:383 +0x60 encoding/json.(*decodeState).unmarshal(0x44e060, 0x111820, 0x1f7264, 0x44e078, 0x0, 0x0) /usr/local/go/src/encoding/json/decode.go:180 +0x240 encoding/json.Unmarshal(0x454000, 0x11a, 0x120, 0x111820, 0x1f7264, 0x11a, 0x120, 0x40e158) /usr/local/go/src/encoding/json/decode.go:107 +0x180 main.main() /tmp/sandbox652463797/main.go:27 +0xc0
The text was updated successfully, but these errors were encountered:
Thanks for reporting! Looks like a simple bug in the reflection code. Will send a CL shortly.
Sorry, something went wrong.
Change https://golang.org/cl/141537 mentions this issue: encoding/json: always verify we can get a field's value
encoding/json: always verify we can get a field's value
4b36e12
No branches or pull requests
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.11 linux/amd64
Does this issue reproduce with the latest release?
yes. Does not happen with go1.9,but happen with go1.10
What operating system and processor architecture are you using (
go env
)?ubuntu16.04 LTS
What did you do?
https://play.golang.org/p/Kw-Gm5YbkJw
What did you expect to see?
This only happen when
innerType
has a method named with capital letter.If method replace to f(),the panic won't happen.What did you see instead?
The text was updated successfully, but these errors were encountered: