MENU

Fun & Interesting

Type Assertions in Go: the only guide you need!

Flo Woelki 5,169 8 months ago
Video Not Working? Fix It Now

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: https://youtu.be/P7dCWOjRwJA 📝 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/florianwoelki Become a member. https://www.youtube.com/@FloWoelki/membership Discord: https://discord.gg/TnA7drJ Instagram: https://www.instagram.com/flowydev/ LinkedIn: https://www.linkedin.com/in/florian-woelki/ TikTok: https://www.tiktok.com/@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/by/4.0/). The gopher used in the video and thumbnail is inspired by this author. #golang #go #typeassertions #typeswitch

Comment