在Json中使用[] struct

I'm trying to parse JSON to a []struct, the JSON is retrieved from https://api.github.com/events However when I try to access each struct within the array I get an error:

type GITHUB_EVENT does not support indexing

How am I able to access each struct within the array?

func httpGetEvents() {
    eventDataRAW := httpPageGet("https://api.github.com/events", true)
    eventDataJSON := new(GITHUB_EVENT)

    _ = json.Unmarshal([]byte(eventDataRAW), &eventDataJSON)

    fmt.Println(eventDataJSON[0].Id)
}

//--------------------------------------------------------------------------------------//

type GITHUB_EVENT []struct {
    Id    string `json:"id"`
    Type  string `json:"type"`
    Actor struct {
        Id         int    `json:"id"`
        Login      string `json:"login"`
        GravatarId string `json:"gravatar_id"`
        Url        string `json:"url"`
        AvatarUrl  string `json:"avatar_url"`
    } `json:"actor"`
    Repo struct {
        Id   int    `json:"id"`
        Name string `json:"name"`
        Url  string `json:"url"`
    } `json:"repo"`
    Payload struct {
        PushId       int    `json:"push_id"`
        Size         int    `json:"size"`
        DistinctSize int    `json:"distinct_size"`
        Ref          string `json:"ref"`
        Head         string `json:"head"`
        Before       string `json:"before"`
        Commits      []struct {
            Sha    string `json:"sha"`
            Author struct {
                Email string `json:"email"`
                Name  string `json:"name"`
            } `json:"author"`
            Message  string `json:"message"`
            Distinct bool   `json:"distinct"`
            Url      string `json:"url"`
        } `json:"commits"`
    } `json:"payload"`
    Public    bool   `json:"public"`
    CreatedAt string `json:"created_at"`
}

This statement:

eventDataJSON := new(GITHUB_EVENT)

declares eventDataJSON as *GITHUB_EVENT (a pointer to a slice), and initializes it as a nil pointer. After unmarshaling, you could access the first event by explicitly deref-ing the pointer before indexing:

(*eventDataJSON)[0].Id

However, the more conventional approach is to use make:

eventDataJSON := make(GITHUB_EVENT, 0)

which declares eventDataJSON as a GITHUB_EVENT, and initializes it as an empty slice. (Remember that make is for special built-in types such as slices, maps, and channels).

You could pass a pointer to this slice to json.Unmarshal:

_ = json.Unmarshal([]byte(eventDataRAW), &eventDataJSON)

...and then index the slice directly:

fmt.Println(eventDataJSON[0].Id)

Additionally, json.Marshal will take care of allocating the output value, so you could declare eventDataJSON and skip any explicit initialization:

var eventDataJSON GITHUB_EVENT

Example: http://play.golang.org/p/zaELDgnpB2