2min chapter

Go Time: Golang, Software Engineering cover image

Reflection and meta programming

Go Time: Golang, Software Engineering

CHAPTER

How to Write Defensive Code

The Reflect API to interrogate those struct tags actually is quite good. It's quite a simple API because some of the Reflect package is it's so meta, isn't it? And some of it makes sense. Like if you try and get the length of an integer, you know, of course the methods are there in the Reflect package to do that. So at compile time, you could do it. It's only then at runtime, you're going to find out you can't get thelength of an integer. There's lots of examples of that. You'd be very verbose when it comes to kind of writing defensive code to make sure that you're not going to have any

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