GitHub Actions Usage, in Go

While I was writing the GitHub CLI Extension gh-actuse, GitHub was working on an approach for binary extensions written in Go. I did consider adopting it at the time, but it looked like it was pretty bleeding edge, and that I was likely to be paying the price for adopting it early. Once gh-actuse was released, I waited for GitHub to make more progress and in Jan 2023, GitHub announced their support for binary extensions was ready for use.


I considered simply rewriting the existing extension in the same repository over to Go, but I wasn’t sure if people already using gh-actuse would all want to use a version written in Go. Many developers and operations staff have a working knowledge of bash scripting, and although Golang isn’t a fringe language at this point, there are still lots of developers with a limited knowledge of Go.

I also wasn’t sure if there were going to be any gotchas in porting to a binary extension, and finally GitHub is talking about adding support for nested extensions:

We intend to add support for nested extensions–in other words, an extension called as a subcommand of an existing gh command like gh pr my-extension–making third-party extensions fit more naturally into our command hierarchy.

This makes me think that there’s a possibility to eventually support an extension that could be invoked as gh actions usage, so I decided to take a step in that direction with a new repository, gh-actions-usage.


I was hoping that invoking APIs through a single Go process would be significantly faster than invoking the gh client over and over from Bash, particularly for a larger organization, and that does seem to have paid off, using one of my clients’ GitHub Organizations as a testbed:

❯ hyperfine "gh actuse <Org>" "gh actions-usage <Org>"
Benchmark 1: gh actuse <Org>
  Time (mean ± σ):     59.223 s ±  5.922 s    [User: 10.419 s, System: 4.347 s]
  Range (min … max):   54.567 s … 73.744 s    10 runs

Benchmark 2: gh actions-usage <Org>
  Time (mean ± σ):     17.701 s ±  1.408 s    [User: 0.099 s, System: 0.047 s]
  Range (min … max):   16.015 s … 20.202 s    10 runs

  'gh actions-usage <Org>' ran
    3.35 ± 0.43 times faster than 'gh actuse <Org>'

The binary extension is over three times faster for this organization and although your mileage may vary (YMMV) in terms of how much faster gh-actions-usage is, it seems safe to predict that the new extension is likely to be faster for almost everyone.

Try It

Give the new extension a try. Let me know if it works for you, report any issues you encounter, or features that you’d like (particularly ones the API could support).