This library is made to access the Codecov REST API, allowing programmatic management of the resources exposed through it.
First, generate a Codecov API token for your user at https://codecov.io/account/gh/<user>/access
. You will need it in order to authenticate against the API.
Bring the library into your project with:
go get github.com/taiidani/go-codecov
And that's it!
Listing all repositories for your user:
c := codecov.NewClient("<token>")
repos, err := c.ListRepositories(context.Background(), "<username/org>")
if err != nil {
panic(err)
}
for _, repo := range repos {
fmt.Println("%#v", repo)
}
Extracting data for a single repository:
c := codecov.NewClient("<token>")
repo, err := c.GetRepository(context.Background(), "<username/org>", "<repo>")
if err != nil {
panic(err)
}
fmt.Println("%#v", repo)
Issues and Pull Requests are welcome! If you would like to test locally, fork and clone this repository, then run:
go test ./...