I just released new Travis CI API client in Go, which is called shuheiktgw/go-travis, so let me introduce why I built it and how to use it.
Why I started developing shuheiktgw/go-travis
Originally, I was just looking for a Travis CI API's client library in Go to kick a build from a CI environment, and found Ableton/go-travis. Unfortunately, there are a few problems with the library.
- It does not seem to be maintained anymore.
- It uses API v2, whose latest version is v3.
- It only supports limited number of endpoints.
In short, I found a vacuum in the field of Travis CI API client in Go, and I was simply thrilled that I might be the first one to fill it.
Also, I used Travis CI for my private projects a lot, so I thought building a Golang client library for them may be a good way to return a favor.
How it works
The way shuheiktgw/go-travis works is deadly simple. Its implementation is heavily inspired by google/go-github (as Ableton/go-travis does), so if you have used go-github, you can instantly understand how it works.
$ go get github.com/shuheiktgw/go-travis
client := travis.NewClient(travis.ApiComUrl, "TravisApiToken") // List all the builds which belongs to the current user _, err := client.Builds.List(context.Background(), nil)
travis.NewClient takes two arguments,
baseUrl, you need to choose either
travis.ApiOrgUrl, so please read URL section.
travisToken can be empty, but then you probably need to authenticate via GitHub token. So please check out Authentication section too for more detailed information on authentication.
- Supports all the endpoints of Travis CI API v3! :tada:
- Does not support Eager loading so far..
That's all, and thank you for reading the post! If you have chance to use shuheiktgw/go-travis, I'd love to hear your feedbacks. Also, contributions to the library are, of course, always welcomed!