octokit/go-octokit — pull request #42 by jingweno (2013-12-10 15:10:28+00:00)
Title: Public / Private Gists return 0

When getting user information, `PublicGists` is always `0`. After an hour+ digging in go-octokit and go-sawyer, I can't figure it out :frowning:

```go
//octo.go
package main

import (
"fmt"
"github.com/octokit/go-octokit/octokit"
)

func main() {
client := octokit.NewClient(nil)
user_url, _ := octokit.UserURL.Expand(octokit.M{"user": "sferik"})
user, _ := client.Users(user_url).One()
fmt.Println("Login: ", user.Login)
fmt.Printf("Followers: %v\n", user.Followers)
fmt.Printf("Public Repos : %v\n", user.PublicRepos)
fmt.Printf("Public Gists: %v\n", user.PublicGists)
}
```

run:

```term
$ go run octo.go
Login: sferik
Followers: 851
Public Repos : 63
Public Gists: 0
```

For fun, I added this

```diff
diff --git a/octokit/users.go b/octokit/users.go
index 569d7ca..d5ec0db 100644
--- a/octokit/users.go
+++ b/octokit/users.go
@@ -58,6 +58,8 @@ type User struct {
Bio string `json:"bio,omitempty"`
PublicRepos int `json:"public_repos,omitempty"`
PublicGists int `json:"public_gists,omitempty"`
+	PrivateGists int `json:"private_gists,omitempty"`
+	DiskUsage int `json:"disk_usage,omitempty"`
Followers int `json:"followers,omitempty"`
Following int `json:"following,omitempty"`
HTMLURL string `json:"html_url,omitempty"`

```

and then modified my `octo.go` to make an authenticated call:

```go
//octo.go
package main

import (
"fmt"
"github.com/octokit/go-octokit/octokit"
)

func main() {
client := octokit.NewClient(octokit.NetrcAuth{})
user_url, _ := octokit.CurrentUserURL.Expand(nil)
user, _ := client.Users(user_url).One()
fmt.Println("Login: ", user.Login)
fmt.Printf("Followers: %v\n", user.Followers)
fmt.Printf("Public Repos : %v\n", user.PublicRepos)
fmt.Printf("Public Gists: %v\n", user.PublicGists)
fmt.Printf("Private Gists: %v\n", user.PrivateGists)
fmt.Printf("Disk Usage: %v\n", user.DiskUsage)
}

```

Which gets me this:

```shell
$ go run octo.go
Login: catsby
Followers: 60
Public Repos : 113
Public Gists: 0
Private Gists: 0
Disk Usage: 134841
```

I tried reproducing this with raw go-sawyer and a Sinatra app that just spit out `private_gists` and `public_gists`, but it worked fine..

I do in fact have both private and public gists, and Erik has public gists:

```shell
$ curl -s -u ***token***:x-oauth-basic https://api.github.com/user | grep _gists
"public_gists": 24,
"private_gists": 150

$ curl -s https://api.github.com/users/sferik | grep _gists
"public_gists": 67
```

Any ideas? What am I missing?