Reputation: 1753
Learning Go and try to get the release list of golang/go with go-github.
Here is my code:
package main
import (
"github.com/google/go-github/github"
"fmt"
)
func main() {
client := github.NewClient(nil)
opt := &github.ListOptions{Page: 2, PerPage: 10}
releases, rsp, err := client.Repositories.ListReleases("golang", "go", opt)
if err != nil {
fmt.Println(err)
}
fmt.Printf("\n%+v\n", releases)
fmt.Printf("\n%+v\n", rsp)
}
When I run it, the release list is empty (as below):
[]
github.Rate{Limit:60, Remaining:59, Reset:github.Timestamp{2015-12-05 14:47:55 +1100 AEDT}}
I don't know what I am doing wrong.
Upvotes: 3
Views: 1716
Reputation: 629
Taking a closer look at the Go repository, the releases are actually just tags and not Github releases, that's why it's returning an empty array. Try this:
// https://api.github.com/repos/jp9000/obs-studio/releases
releases, rsp, err := client.Repositories.ListReleases("jp9000", "obs-studio", opt)
This should correctly return all releases for jp9000's obs-studio repository.
Original Answer:
Looking at the docs, the code looks good but this might be an issue with Github's API though. For instance, if you go to https://api.github.com/repos/golang/go/releases you get an empty array, but if you search for the tags using https://api.github.com/repos/golang/go/tags it lists all tasks without any problem.
And if you go to https://api.github.com/repos/golang/go/releases/1 you get a 404. I took these addresses from the Github Developer's page: https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
Upvotes: 2