Type Assertions and the Type Switch in Go are concepts that you need to understand to fully master any types in Golang! If you also need a quick refresher of Golang, feel free to check out this video here: • Go from Zero to Hero: Learn Golang in...
📝 Description
Struggling with determining variable types in Go interfaces? This video dives deep into type switches and type assertions - powerful tools for handling different logic based on variable types in Go. We'll cover:
• Basic type assertions and why they're different from casting
• Dynamic method checking with type assertions
• Combining type switches with generics for flexible type handling
• Real-world use cases demonstrating error handling with custom error types
• Pros and cons of if-else type assertions vs type switches
⏳ Timestamps:
00:00 - Introduction
01:00 - Type Assertions
04:30 - Type Assertions & Methods
06:25 - Type Switch & Generics
09:26 - Type Switch use case
17:29 - Outro
👋 Hey there!
If you are new to this channel: Hey 👋 my name is Flo and I am a professional software engineer with a passion for coding in Golang, TypeScript, JavaScript, and Rust. This channel is where I share that passion and dive into the exciting world of software engineering. Plus, I love using emojis and paper-based animations (so have a look for that if you want to find my videos).
📨 Support and Connect!
Buy me a coffee: https://www.buymeacoffee.com/florianw...
Become a member. / @flowoelki
Discord: / discord
Instagram: / flowydev
LinkedIn: / florian-woelki
TikTok: / florianwoelki
GitHub: https://github.com/FlorianWoelki
📝 Copyright Notice
The original Go Gopher version is originally designed by Renée French (Source: https://go.dev/blog/gopher License details: https://creativecommons.org/licenses/.... The gopher used in the video and thumbnail is inspired by this author.
#golang #go #typeassertions #typeswitch