2min chapter

Changelog Master Feed cover image

The bits of Go we avoid (and why) (Go Time #269)

Changelog Master Feed

CHAPTER

How to Avoid Global State in Your Code

I would actually do away with global state altogether. If you're going to try and sort of mock it or something, it'll interfere with it in weird ways. I think that the key is with usages of global state that aren't bad is they're essentially constant. So some of those, you can't actually use the const keyword because for example, the file store has to be a fs variable so there's no such thing as anfs constant. But once the application starts up, you're not changing it. You're not modifying it. Yeah. It probably shouldn't live at the package level after if you're modifying it after startup. That's pretty much a very clear bright

00:00

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode