Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: decoding JSON into anonymous struct works in go 1.8.7 but fails silently in go 1.9.4 #23861
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
You two both forgot to check for errors.
That might not necessarily matter, but it's a distracting bug report, since everybody will immediately assume the answer is in the ignored error.
changed the title
decoding JSON into anonymous struct works in go 1.8.7 but fails silently in go 1.9.4
Feb 15, 2018
An exported field works: https://play.golang.org/p/0kdRTJY_Xp5
Capitalizing the type works: https://play.golang.org/p/4szuu5Zydg3
Yes, this is expected behavior.
According to the language spec:
Thus, embedding a builtin type results in a field name that is not exported (since all builtin have lowercase names). Since this is unexported, the
The example you provided has an anonymous string, not a struct.