DEV Community

Alex Pliutau
Alex Pliutau

Posted on

Year Of Commits: simple systray program in Go

Happy New Year Gophers! One of my goals for 2018 is to commit a code to GitHub every single day. So "Contributions" on GitHub will look like this:


To track this process I decided to write a Go program, which will be always in my tray, and which will show how many days in a row I committed something to Github.

Tadaa! yearofcommits

It's a single-file command line tool using the following packages:


We're installing them using dep.

systray is a cross-platform package to place an icon and menu into notification area. Though I tested it only on Mac.

Then application uses GitHub API with help of go-github/github Go package. GitHub API doesn't have contributions endpoint, so we need to get all repositories and get all commits made by specified user.

client.Repositories.List(ctx, user, reposOpts)
client.Repositories.ListCommits(ctx, user, repo.GetName(), commitsOpts)
Enter fullscreen mode Exit fullscreen mode

The rest is easy, count days.


To run it in locally you need to install dep and run:

dep ensure
go install
yearofcommits -u github_user -t github_api_token
Enter fullscreen mode Exit fullscreen mode

Also, if you want keep it running even after you restart your Mac, you can configure launchctl. Create /Library/LaunchAgents/yearofcommits.plist file with the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">




Enter fullscreen mode Exit fullscreen mode

Change /go/bin/yearofcommits to the absolute path inside your $GOBIN.


sudo launchctl load /Library/LaunchAgents/yearofcommits.plist
Enter fullscreen mode Exit fullscreen mode

Origin post in my Blog

Discussion (0)