MENU

Fun & Interesting

You are providing fallback values in Golang wrong!

Flo Woelki 4,416 11 months ago
Video Not Working? Fix It Now

Golang 1.22 has a brand new feature, the cmp.Or function. If you want to know everything about structs, I highly recommend watching this video: https://youtu.be/c8H0w4yBL10. 📝 Description In this video, we delve into the power and versatility of the `cmp.Or` function in Golang. This function, a part of the `cmp` package, allows us to streamline our code and make it more readable and efficient. We start by discussing the general functionality of the `cmp.Or` function, including its ability to return the first non-zero value from a list of arguments. Then, we walk you through several practical use cases, such as configuring a web server's port, handling optional user input in a chatroom, and optimizing sorting of a slice of structs. ⏳ Timestamps: 00:00 - Introduction 00:31 - What is the cmp.Or function 01:50 - 1. Use Case: Fallback Values 05:23 - 2. Use Case: More Fallback Values 08:18 - 3. Use Case: Sorting 12:45 - 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 #golang1.22

Comment