Tradition vs. Innovation - The Applied Go Weekly Newsletter 2024-06-23
Your weekly source of Go news, tips, and projects
Go's language specification is rock stable, compared to other languages (looking at you, C++!). The Go team is very careful about approving new features to the language, and yet, Go has gotten type parameters (aka generics) and is about to get new function iterators. Not to mention the Go Module system that replaces the old single-workspace paradigm (aka GOPATH) since Go 1.11 (here is a brief history).
And while Go is slowly but steadily moving forward, external influences change the Go ecosystem as well. While frameworks are generally frowned upon in Go, once in a while, Yet Another Framework™ pops up, aiming at lowering the entry barriers for Web or microservice development, while long-term Gophers keep pointing out that Go is inherently a library-focused language, supporting the composition of functionality from independent modules for maximum flexibility. (Count me in.)
What do you think about Go's past and future? Are we on the edge of "too much" already? Would you be able, or even happy, to work with a pre-generics version of Go? Is Go just another tool in your dev stack, or is it a state of mind?
Hit reply and let me know, or comment on one of the announcements for this issue on Mastodon, LinkedIn, or X, once they are sent out (planned for Tuesday June 25th).
Have a fulfilling week!
Why People are Angry over Go 1.23 Iterators
Does Go become too functional? Are the new iterators alien to the procedural nature of Go? Thoughts from Ginger Bill, the designer of the Odin language.
Why People are Angry over Go 1.23 Iterators
A pragmatic guide to Go module updates
Increasing a dependency's version is quite straightforward, until you need to upgrade to a new major version. Carlos Becker shares some tips on this, and also insights on using modules inside a monorepo.
A pragmatic guide to Go module updates
Caesar
Is Caesar Go's Django? The creators of this web framework claim that even though frameworks are frowned upon in Go, they make sense in the complicated web application space.
Podcast corner
Cup o' Go | Cup o' Go Live from Amsterdam!
Shay and the co-hosts Erik Dubbelboer, John Basila, Suchith, and Hiji recorded this episode live from Amsterdam! (What were they doing in Amsterdam?!)
Is Go evolving in the wrong direction? (Go Time #319)
Go aims to be a simple, boring language, yet a recent addition (generics) and an upcoming addition (iterators) to the core language make many wonder if Go slowly loses its "easy to read, easy to comprehend" status. (See also the previous newsletter issue.) Kris and Ian discuss this and other news from the Go community.
go podcast() | 040: CLI in Go and other tech talks with Marian Montagnino
Marian Montagnino is the guest in this episode of go podcast()
. He talks to Dominic St-Pierre about CLI apps in Go (and other languages). Marian is the author of the book "Building Modern CLI Applications in Go".
Go tip of the week: How to (not) rename a public module
Renaming a module? How's that a problem? If you want to rename a private module only used in your projects, renaming is indeed quite straightforward, at least with support from the IDE or a bash script.
But what if your module is public, and used by hundreds or thousands of client projects? (In this case, congrats to you.) Simply renaming the module would break tons of imports, so you need a plan.
Step 0: Think hard if the module really, really needs a new name (or a new path). Your users are used to the current import path, so why not leave the module path alone?
There are, of course, legitimate reasons for a change. For example, the project moves over to another organization. Or you discovered that the module name is a nasty word in Kenyan or Icelandic, like an insult of the king or the equivalent of one of those four-letter words. (As a rule of thumb: don't insult a king, and don't swear and curse in public, except if your target audience expects this from you.)
Once you have decided to change the module path, you might be tempted to use the automatic redirection service of your VCS hosting provider. GitHub, for example, automatically redirects traffic of a renamed repository to the new name, but there is a pitfall: If, at some fine day, you create a new repository of the same name as the old one, all redirects to the renamed repository stop.
So better look for a pure-Go solution.
Here are steps I found to be sort of a common recommendation, and they aren't too complicated, although you'd probably wish for a simpler version (with support from the Go toolchain). (Note that I'm strictly looking at single-module repositories. Modules inside monorepos have a few more cases to consider.)
Here we go. Say you're on GitHub and want to rename your module from github.com/oldorg/oldrepo
to github.com/neworg/newrepo
. (It doesn't matter if you want to change the organization name, the repository name, or both.) Then do these steps:
- Copy the current repository over to the new path. This could be a fork on GitHub, or whatever mechanism your VCS or VCS hosting service provide.
- Update
go.mod
in the new repository. Change themodule
directive to the new path, which, in this example, ismodule github.com/neworg/newrepo
. - Deprecate the old module. Add a deprecation message to the
go.mod
file. This is a comment before themodule
directive (or after the directive, in the same line) starting with// Deprecated:
(see the subsection "Deprecation" under "module
directive" in the module reference for details). - Provide clear migration instructions. In the old module's documentation, describe the steps users of your module must take to migrate over to the new module.
Your module users would need to do these migration steps:
- Update their
go.mod
file to require the new module - Update all
import
statements in their code to use the new path - Run
go mod tidy
to let Go do the housekeeping.
After some weeks or months, you may consider archiving the GitHub repository (or doing an equivalent step, depending on your VCS hosting provider) to make the message even more clear.
In any case, don't skip Step 0. Could be a time saver.
Quote of the week: the strongest feature
Surprisingly I'm thinking about how good Go is quite often. For me, not only it has those built-in concurrency features which are a strong plus, the way the language is designed and how fun it is for me to write code in it is the strongest feature in Go. It's just made well, and I'm here for that.
More articles, videos, talks
Going from Development to Production with a simple gitops all golang setup
If you are looking for a lightweight GitOps stack, Redditor /u/gedw99
has shared their stack setup, guaranteed to be free of any "heavy stuff". Bonus points for using Go-based tools across the stack. ʕ◔ϖ◔ʔ
OTel Collector - Blog by Roman Glushko
The OpenTelemetry Collector is designed to offload observability processing from applications. In this article, Roman Glushko explores how to implement a custom OTel Collector (including a few words on the OTel Collector Builder for Go.)
Sqlc: 2024 check in — brandur.org
Three years after choosing to use sqlc
for their Go stack instead of any ORM or query builder, Brandur draws a few conclusions about their experience with this schema-first code generator. TL;DR: sqlc
has some edge cases where queries become unwieldy, but overall the team does not regret the choice. "We’re able to express very complex queries involving CTEs and subqueries that would look like absolute train wrecks if encoded in the DSL of an ORM", Brandur points out.
Loggerhead: Because Reinventing The Wheel Is Fun
About building an in-memory geolocation database even though such beasts exist already.
On testing Go code using the standard library | Henrique Vicente
You probably don't need a 3rd-party testing framework. It's another domain-specific language to learn, with unclear benefits. Henrique Vicente shares some tips on making full use of the stdlib's testing features.
Projects
Libraries
Going from Development to Production with a simple gitops all golang setup
If you are looking for a lightweight GitOps stack, Redditor /u/gedw99
has shared their stack setup, guaranteed to be free of any "heavy stuff". Bonus points for using Go-based tools across the stack. ʕ◔ϖ◔ʔ
OTel Collector - Blog by Roman Glushko
The OpenTelemetry Collector is designed to offload observability processing from applications. In this article, Roman Glushko explores how to implement a custom OTel Collector (including a few words on the OTel Collector Builder for Go.)
Sqlc: 2024 check in — brandur.org
Three years after choosing to use sqlc
for their Go stack instead of any ORM or query builder, Brandur draws a few conclusions about their experience with this schema-first code generator. TL;DR: sqlc
has some edge cases where queries become unwieldy, but overall the team does not regret the choice. "We’re able to express very complex queries involving CTEs and subqueries that would look like absolute train wrecks if encoded in the DSL of an ORM", Brandur points out.
Loggerhead: Because Reinventing The Wheel Is Fun
About building an in-memory geolocation database even though such beasts exist already.
On testing Go code using the standard library | Henrique Vicente
You probably don't need a 3rd-party testing framework. It's another domain-specific language to learn, with unclear benefits. Henrique Vicente shares some tips on making full use of the stdlib's testing features.
Tools and applications
GitHub - nidorx/go-bench-viewer: Easy and intuitive Go Benchmark Results Viewer.
Tired of wading through tons of text output from your benchmark runs? Copy&paste that benchmark gibberish into this website and get colored charts back to grasp the results at a glance.
GitHub - murat-cileli/dbee: TUI based database browser.
No, it doesn't always have to be DBeaver if you want to inspect a database. DBee is a lightweight TUI app for quick database browsing.
GitHub - mortenson/go-template-transpiler-extension: Go Template Support in VSCode via Transpiling
The Go language server gopls
does not support Go templates. Except that it does now, at least in VSCode, thanks to this extension that transforms templates into a format digestible by gopls
.
GitHub - itzloop/misura
Misura generates wrappers around Go interfaces to inject metrics collection and tracing.
GitHub - pspiagicw/qemantra: Control QEMU like magic!
A command-line tool for creating and managing QEMU virtual machines.
Completely unrelated to Go
UUIDv7 in 31 languages
The 7th version of the UUID specification ships time-sortable UUIDs. Before you rush to the module supermarket, here is how to implement UUIDv7 without any dependencies, in 31 languages, including Go. Collected and partially enabled for immediate execution (uh, that sounds harsh! What I meant is, for running the code right in the browser) by Anton Zhiyanov.
What's hidden behind "just implementation details" | nicole@web
"The hard work of architecting and designing is done, the rest is just implementation details". Just? All the "implementation details" can add up to become the real hard part of the work, says Nicole Tietz.
Did you do what I asked for or not? | Sandor Dargo's Blog
If your manager or team lead is your best supporter, coach, and mentor, consider yourself lucky. More often than not, managing style can be... challenging. Sandor Dargo describes an example of an "all-or-nothing" management style. Run for the hills!
I kind of like rebasing | Redowan's Reflections
Merging, squashing, rebasing: The options for managing a project's Git history are as numerous as the opinions about the right way of using them. Granted, there is no one-size-fits-all solution. I daresay it mostly depends on the style of working with code. Redowan Delowar explains his style of programming and how it influences his preferred way of Git history management.
P.S.
I asked three state-of-the-art LLMs to suggest an intro to this newsletter, just to rest assured that manual writing still has a point. How could I believe anything else!
For a language built on simplicity and efficiency, keeping up with modern demands often involves a delicate balancing act. Our newsletter this month addresses this tension head-on with discussions on the divisive new iterators in Go 1.23, advice for updating and managing Go modules, and a look at Caesar, a web framework that's challenging Go's minimalistic tradition. Join us as we explore how Go developers can navigate these changes without losing sight of what makes the language unique.
Join me as I fail to explore how anybody can navigate this text without losing their minds.
Or to say it in Dave Harland's words: Fucking shite.
Happy coding! ʕ◔ϖ◔ʔ
Questions or feedback? Drop me a line. I'd love to hear from you.
Best from Munich, Christoph
Not a subscriber yet?
If you read this newsletter issue online, or if someone forwarded the newsletter to you, subscribe for regular updates to get every new issue earlier than the online version, and more reliable than an occasional forwarding.
Find the subscription form at the end of this page.
How I can help
If you're looking for more useful content around Go, here are some ways I can help you become a better Gopher (or a Gopher at all):
On AppliedGo.net, I blog about Go projects, algorithms and data structures in Go, and other fun stuff.
Or visit the AppliedGo.com blog and learn about language specifics, Go updates, and programming-related stuff.
My AppliedGo YouTube channel hosts quick tip and crash course videos that help you get more productive and creative with Go.
Enroll in my Go course for developers that stands out for its intense use of animated graphics for explaining abstract concepts in an intuitive way. Numerous short and concise lectures allow you to schedule your learning flow as you like.
Christoph Berger IT Products and Services
Dachauer Straße 29
Bergkirchen
Germany