Closed Kissaki closed 11 years ago
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:
package main
import (
"log"
githubapi "github.com/google/go-github/github"
)
func main() {
github := githubapi.NewClient(nil)
uname := "Kissaki"
_, err := github.Users.Get(uname)
if err != nil {
log.Fatalf("Failed to find user %s. Error: %s\n", uname, err)
} else {
log.Printf("Found user %s\n", uname)
}
}
running that script, I get:
% go run main.go
2013/06/23 10:23:37 Found user Kissaki
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. I guess the behaviour changed from Go version 1.0 to 1.1.
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.