Don't mock slog

October 25, 2023

Are you excited to hit the ground running with Go 1.21’s new log/slog package? That means testing it, right? And testing means mocks, right? Not so fast! Don’t mock slog! In my latest video, I talk about the problems with mocking, and the super simple alternative you can use when testing code that uses the new slog package.

Share this

Direct to your inbox, daily. I respect your privacy .

Unsure? Browse the archive .

Related Content

Wanted: Your Go code to review

In next week’s live stream, I’m going to be reviewing Go code from you, the Boldy Go community. I’ll be looking at three or four projects, which I have never seen before, and offering my feedback. And that’s where you come in. I’d love to review your code! Do you have a Go project on GitHub that you’d like to have reviewed? Maybe it’s a take-home coding assignment you did as part of an interview process, and you’d like some more constructive feedback than you got from the recruiter who ghosted you.


There are a number of terms that get thrown around, often semi-interchangeably by the less initiated (such as myself). “Declaration”, “definition”, “statement”, … and today’s topic “expressions”, just to name a few. But, at least within the context of the Go spec, most such terms have very specific meanings. Expressions An expression specifies the computation of a value by applying operators and functions to operands. So: type foo int and var foo int are not an expressions.

Go 1.21 has been released!

I’m a couple days late with the news… so you hopefully didn’t hear it here first. But two days ago, Go 1.21 was released. This means the Go spec has changed! Today I’ll highlight the main changes introduced to the spec in Go 1.21. None of the changes substantially impacts topics we’ve already covered in the spec series, so I won’t be going back to re-explain changed parts of the spec we’ve already covered.