I have started learning Go and I find it quite interesting so far. As an assignment for myself to get get better at the language, I decided to write a Gister in Go using go-github.
I have been able to get all my Gists using an access token and I am able to print as follows:
package main
import "fmt"
import "github.com/google/go-github/github"
import "code.google.com/p/goauth2/oauth"
func main() {
t := &oauth.Transport{
Token: &oauth.Token{AccessToken: "secretaccesstokenhere"},
}
client := github.NewClient(t.Client())
gists, _, err := client.Gists.List("", nil)
if err != nil {
fmt.Println(err)
} else {
for _, g := range gists {
fmt.Printf("%v
", g.Files)
}
}
}
And I get the following output:
map[TODO.md:github.GistFile{Size:166, Filename:"TODO.md", RawURL:"somerawurlhere"}]
map[fourcore.c:github.GistFile{Size:309, Filename:"fourcore.c", RawURL:"somerawurlhere"}]
map[coretest.cpp:github.GistFile{Size:160, Filename:"coretest.cpp", RawURL:"somerawurlhere"}]
What I would like to print is "ID / FILENAME". I understand that I need to extract the ID from Gist type and Filename from above map but I wasn't able to find a way to do that. How do I do that? Help would be greatly appreciated.
P.S: Here is the documentation describing Gist type.