Happy late new year

January 7, 2026

I kinda fell off the planet for a while with family, holidays, and… writers’s block. But I’m back now, and prepared to take the time to come up with (hopefully) interesting things to write about again.

Today I’m going to talk about a new feature coming in Go 1.26, which relates to my series earlier in 2025 about contexts.

The new feature is mentioned very briefly in the release notes:

os/signal

NotifyContext now cancels the returned context with context.CancelCauseFunc and an error indicating which signal was received.

If you aren’t already quite familiar with the idea of context cancel causes, this new feature won’t make much sense. But not to worry! I explained those before!

But here’s the TL;DR;

  • You can create a context that can be canceled with a ‘cause’, which allows you to…
  • call the ‘Cause()’ method on the context, after its canceled, to get a more descriptive error message than the default ‘context canceled’ or ‘context deadline exceeded’.

And now, signal.NotifyContext will include a cause whenever the context is canceled due to a signal being received. This allows you to potentially treat SIGTERM and SIGINT differently in your graceful shutdowns, for example.

Woot!


Share this

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

Unsure? Browse the archive .

Get daily content like this in your inbox!

Subscribe