-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
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
Getting a User object with null fields fails #9
Comments
Are you actually seeing these marshaling errors in practice? I've tried writing a sample test that causes an error, but am unable. Could you post an example, either here or in a pull request? |
A simple script that leads to the unmarshalling error:
|
running that script, I get:
What version of Go are you running? I've tried both 1.0.3 and 1.1, and neither throw an error for me. |
I’m running a 1.0.3 on Windows 7 x64 here. |
With Go 1.1.1 on Windows 7 x64 this is no longer an issue. So unless functionality for Go 1.0 is a goal here, I’m fine with closing this. |
ah, cool... thanks for following up on this. I'll close this out, but maybe we can start a "known issues" page somewhere, and mention this. |
The github API v3 declares that blank fields are included with a null as the value instead of being omitted.
For a user which did not specify an organisation, blog or bio the Get returns
null
as the field values.In go-github this leads to an unmarshalling failure as type string is defined in the struct type User. Unfortunately, null can not be unmarshalled/mapped to string.
A potential solution may be to change the type from
string
to pointers, allowingnil
.But then this should probably be implemented as a general concept across the library, as the API docs state that generally empty fields are returned as null values - and does not seem to note which fields can be empty/null in the end.
The text was updated successfully, but these errors were encountered: