You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
panic: reflect: reflect.Value.Set using value obtained using unexported field [recovered]
panic: interface conversion: string is not error: missing method Error
This is (sort of) working as intended. The json package was relying on a bug in the reflect package. @mdempsky fixed that bug. The work to be done is to get json.Unmarshal to not panic.
Fundamentally, it is impossible for json to unmarshal into Manager.employee because it can't assign into an unexported field. The Go language spec forbids that.
What version of Go are you using (
go version
)?commit 812b34e: good
commit d349fa2: bad
Does this issue reproduce with the latest release?
the issue reproduces on master, it is not on the 1.9 release branch
What operating system and processor architecture are you using (
go env
)?freebsd/amd64
linux/amd64
darwin/amd64
windows/amd64
What did you do?
https://play.golang.org/p/6ABGl7lNJA
What did you expect to see?
1
What did you see instead?
panic: reflect: reflect.Value.Set using value obtained using unexported field [recovered]
panic: interface conversion: string is not error: missing method Error
goroutine 1 [running]:
encoding/json.(*decodeState).unmarshal.func1(0xc42003bed8)
/usr/home/user/dev/golang/src/encoding/json/decode.go:175 +0x8f
panic(0x4b20c0, 0xc420072210)
/usr/home/user/dev/golang/src/runtime/panic.go:492 +0x266
reflect.flag.mustBeAssignable(0x1d6)
/usr/home/user/dev/golang/src/reflect/value.go:224 +0x200
reflect.Value.Set(0x4aca20, 0xc42008c018, 0x1d6, 0x4aca20, 0xc420072200, 0x16)
/usr/home/user/dev/golang/src/reflect/value.go:1344 +0x2f
encoding/json.(*decodeState).object(0xc42009a000, 0x4ac9e0, 0xc42008c018, 0x16)
/usr/home/user/dev/golang/src/encoding/json/decode.go:707 +0x3fa
encoding/json.(*decodeState).value(0xc42009a000, 0x4ac9e0, 0xc42008c018, 0x16)
/usr/home/user/dev/golang/src/encoding/json/decode.go:405 +0x2d8
encoding/json.(*decodeState).unmarshal(0xc42009a000, 0x4ac9e0, 0xc42008c018, 0x0, 0x0)
/usr/home/user/dev/golang/src/encoding/json/decode.go:187 +0x201
encoding/json.Unmarshal(0xc420086050, 0xb, 0x10, 0x4ac9e0, 0xc42008c018, 0x10, 0x49f939)
/usr/home/user/dev/golang/src/encoding/json/decode.go:107 +0x148
main.main()
/home/user/dev/go/src/serializer/main.go:10 +0xa
The text was updated successfully, but these errors were encountered: