2026-09-06

I had a bit more of a think about that Unsung post about responsive code blocks. Apparently there exists a package which can format Go code assuming a certain width. It can also adjust the tab width and reflow comments and method calls. I asked GPT-6 Astra Light to build a quick playground for me to test it:

Prompt to Astra

In webtools is a set of basic web-tools. I would like you to add a new tool for testing out golines, shown here: github.com/golangci/… There should be a package version of this called shorten, documented here: pkg.go.dev/github.co…

What I’m thinking is a new tool which takes as input a Go program. It will use shorten to format the Go input and render it as output. There should be a slider allowing the user to adjust the Config.MaxLen (min width = 40, max width = 180, step = 5). Other config should be as follows:

  • TabLen = 4, unless MaxLen < 80, then 2
  • ShortenComments = true
  • ReformatTags = true
  • ChainSplitDots = true

Try to produce a WASM target for this, much like some of the other tools in this project.

It was my first test of Astra actually, and I was quite happy with what it produced:

Auto-generated description: A web-based Golines Playground interface displays side-by-side panels with Go programming language code on the left and its formatted output on the right.

Anyway, adding something like this for Go code on this site might be viable. My current thinking is adding a module to Blogging Tools which would allow me to copy-paste a Go snippet, which would then be formatted four different ways, based on the assumed client width. I don’t know how that would appear on the site though. Probably one code block which would assume a baseline width, and some JavaScript or CSS which would replace it with something more size appropriate. I’ll also need to work with RSS and PageFind indexing. I’ll have to have a think about that.