Header logo.
small hallucinations
homeyearstagsaboutrss

So I wrote a new static-site generator

I used to generate this blog from Markdown files using my own static site generator written in Python. The resulting HTML files are then hosted on Cloudflare Pages.

At some point late last year, the Python codebase stopped running smoothly because of dependency issues. And I don't remember tweaking my system or Python version, or adding or removing these libraries.

At first, the Markdown parser I used went missing. I had to install it again in a new virtual environment. Then the feed generator complained that an argument was missing in a function call. (These kinds of minor problems will just crop up.)

So I decided to rewrite the SSG behind this blog in Go.

The whole process was pleasant. GitHub Copilot was very helpful. It suggested which dependencies I could use to parse Markdown and to generate RSS feeds (goldmark and gorilla/feeds). It suggested code completion that was often helpful. A few suggested solutions used deprecated function calls but were educational nonetheless.

When you program, old habits from other languages are carried over. Here are a few things I learned while being nudged by Copilot:

  1. Go doesn't support string interpolation with variable names. And there is a whole discussion about it.
  2. Go doesn't support optional args in the function signature. Instead, you can use a variadic function or use an options struct.
  3. I tried to import a struct from the main package in a child package. And that was a dumb idea. Because “importing the main package directly can lead to circular dependencies, which are not allowed in Go.” Instead, I could “move the BlogSetting type to a separate package, which can then be imported by both the main and template packages.”