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
Transcript
Play full episode

Remember Everything You Learn from Podcasts

Save insights instantly, chat with episodes, and build lasting knowledge - all powered by AI.
App store bannerPlay store banner