My Recent Adventures With Go and Homebrew
I’m on holiday, so I have some time to play with code more than usual. Some time ago, for this blog, I wrote a simple script that converted inline markdown links to references1. I wrote it in Ruby, created a Docker image for it, and ran it before each new piece of content was published. I wanted to make it as simple as possible, so other people might use it as well (Docker, no dependencies, available to pull directly from the registry, it runs through Makefile command, etc.).
It worked, but I wasn’t happy with it. I thought that making it available through Homebrew would be a better idea. And when doing this, I also wanted to experiment a little with Go and give Github Copilot a chance (as my coding skills are a bit rusty).
I’m happy to say that I was able to achieve all my goals. All the code is available in the markdown-tools repo, it’s written in Go, there are some tests (thanks, Copilot!) and it’s available through Homebrew. I still have a lot to do before I’ll mark it as a 1.0 release, but it’s a good start. I had a ton of fun writing it; I struggled the most with writing the right regexes:)
Outcome⌗
To summarize the whole gig:
- Repo with the code: markdown-tools
- Updated scripts repository where I store some random stuff I use: lubieniebieski/scripts
- Homebrew tap: lubieniebieski/homebrew-tools
- The process is automated with Github Actions, so I don’t have to do anything manually (well… almost, but the Homebrew formula part is done nicely).
The best part for me is that I can currently focus on improving the tools themselves, fixing some edge cases, and so on, while the release process is automated. I no longer have to worry about it! 💪
Resources⌗
Some useful sites and article I found that helped me to get through the process:
- regex101: build, test, and debug regex
- Create CLI in Go and Publish it to Homebrew | by Mehran | ITNEXT
- How To Build Go Executables for Multiple Platforms on Ubuntu 16.04 | DigitalOcean
- spf13/cobra: A Commander for modern Go CLI interactions
- Homebrew tap with bottles uploaded to GitHub Releases — Homebrew
- Homebrew docs
- Homebrew tap docs
-
I’m not exactly sure why I wanted to have it this way, but that’s a topic for another post. ↩︎