This is cleanup I've been working on in the background that's turning out ok, so let's track it: all the "tables" and "reports" exposed by sonalyze have custom, hand-maintained printing code, meaning the code is maintained in several scattered places and it's a bit of a mess to remember how to maintain it when it needs to change. It's possible to use Go's reflection API to instead generate printers from the structure definitions with some annotations; this brings everything together in one place (with the caveat that there can't easily be multiple different printers for the same data). This is not completely free: code that now performs computation as part of printing must be lifted into a separate computation step that computes the result table that is then printed. But the consequence of doing that is a cleaner separation of concerns.
This is cleanup I've been working on in the background that's turning out ok, so let's track it: all the "tables" and "reports" exposed by sonalyze have custom, hand-maintained printing code, meaning the code is maintained in several scattered places and it's a bit of a mess to remember how to maintain it when it needs to change. It's possible to use Go's reflection API to instead generate printers from the structure definitions with some annotations; this brings everything together in one place (with the caveat that there can't easily be multiple different printers for the same data). This is not completely free: code that now performs computation as part of printing must be lifted into a separate computation step that computes the result table that is then printed. But the consequence of doing that is a cleaner separation of concerns.