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
What does 'go version' print? 1.3
What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Run this: http://play.golang.org/p/EXzXy8Ec01
What happened? There is no error and the struct has no fields set
What should have happened instead? The name field should have been set to foo.
Please provide any additional information below.
Apparently Unmarshal silently ignores field names that are lowercase. If I change the
'name' field in the struct to 'Name', then it works. This is especially painful as
examples in effective go (e.g. https://golang.org/doc/effective_go.html#formatting) show
structs with lowercase fields. Ideally, Unmarshal would handle structs with lowercase
fields. If that isn't practical for some reason, the docs should mention it, and
perhaps Unmarshal should return an error if passed a struct type which has no fields
that are settable.
The text was updated successfully, but these errors were encountered:
Well, perhaps (as I said originally) the docs should mention this and perhaps Unmarshal
could return an error if passed a struct with no exported fields.
Technically, I think it is documented. The Marshal docs say "Each exported struct field
becomes a member of the object." The Unmarshal docs say "Unmarshal uses the inverse of
the encodings that Marshal uses."
I wouldn't object to another sentence in the Unmarshal docs, though.
by ginabythebay:
The text was updated successfully, but these errors were encountered: