- go
- programming
- meta
- hosting
This Site is an Executable Binary
I have a lot of excuses for not writing more, but recently I had a whole list of ideas of things to write and I got caught up in the problem of publishing too many things at once.
This is mostly just a lame excuse, but it led me down a path of trying to find a way to automate post publishing so I could write a bunch of content at the same time and have it slowly trickle out.
My site has run as a static site built with Astro for 3 years. This served me well, except for the fact that publishing a new post was a manual act. Whether pushing to a git repo to trigger a build and deploy or manually building and pushing, in all cases, I could not deploy any content I wanted to show at a later date to my production server.
My initial plan was to setup a workflow in Forgejo that would run on a schedule, check for branches matching a date pattern, if the date was today or earlier, merge it back and deploy the built site. This got complicated and seemed failure prone. I would have had to build at least two new workflows and also remember to name my branches with a date with no validation of the name before the workflow ran. This is not what git does well. So I reached for a tool I have been spending time learning. Go!
I managed to replicate almost everything from Astro in just a couple of days. I can still write in Markdown, have Front Matter. I still have recipes available from Mealie. The one missing piece is publishing Webmentions. As I have never gotten a mention I will add this if it is useful. The best part is now everything is contained in a single go binary with significantly less dependencies than Astro.
I am using Go’s embed to include all content, images, and templates into a single file which can be run with a simple ~/ > ./connermccall-com. Go’s build system also means that it is mostly trivial to build a version for different platforms. So if I provision an ARM machine one day, I can run it there.
This was a fun endeavor and great exercise to push my language knowledge. I really like the fact that I could write, commit, and build the site on Tuesday and have this post go live on Thursday without any intervention at publish time1.
1 Technically this should be date, since currently I just use date strings.