Golang Generics for Beginners (Go generics explained in 2 min)

preview_player
Показать описание
Although, Go has long been praised for its simplicity and straightforward syntax, it has traditionally lacked a key feature found in other languages: generics. But with the recent release of GoLang 1.18, this is no longer the case.

Generics allow you to write more flexible and reusable code by creating functions and data structures that can operate on a wide range of types. This means you can write cleaner, more concise code that is easier to maintain and scale.

In this video, we'll cover how generics work in Golang and the benefits of using generics in your code.

Whether you're a seasoned Go developer or a complete newbie, this video will help you take your code to the next level. So if you're ready to supercharge your code and unlock new levels of productivity, watch this video and don't forget to share with others who have the same doubts!

0:00 Intro
0:26 Creating our structs
1:23 The use case for generics
1:53 Lets implement a generic function to solve
3:00 Wrap up Recap
Рекомендации по теме
Комментарии
Автор

The example doesn't event need the generics.

If you define the function as Introductions(people Humanish) [] string, it would have solved the problem just by using interface as a parameter and then person.Introduce() will give you the same result.

pravandkatyare