Тёмный

Getting Started with Generics in Go 

TutorialEdge
Подписаться 29 тыс.
Просмотров 28 тыс.
50% 1

Опубликовано:

 

27 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 33   
@necroowl3953
@necroowl3953 2 года назад
I honestly waited for you to explain how these would be useful in Go. I am not disappointed once again, and you did a great job explaining it with a practical example. I want to add that it is important to underline that Generics in Go can only be applied when the logic is exactly the same. Otherwise it is always best to type check the inputs via an empty interface (where specific types follow specific logic). One example is JSON marshaling, which cannot be implemented using generics. Thanks for this video, and cheers for giving clarity on this topic.
@capythulhu
@capythulhu 2 года назад
Generics aren't alternatives to type checking, they work well together. If you were implementing a Power function without generics, for example, you would have to create two functions for numbers in general: floatPower(n float64) and intPower(n int64). If you wanted to make it possible for types of every size, you'd have to create even more functions such as: float32Power(n float32), int8Power(n int8), etc. Or, you could use the empty interface approach, but you would have to treat cases such as power("hello"). That means you would have to either have the possibility of a unexpected behavior or you would have to return an error, so you'd have to check that error _every single time_ you call that function just because it is syntactically possible for the user to send something that's not a number into your function. With Go generics, you can just have a func power[num int8 | int16 | int32 | int64 | float32 | float64](n num) and still perform the type check for different operations, if that's the case.
@javisartdesign
@javisartdesign 2 года назад
Awesome, I think it `s something to expect in a language these days. Since you cannot cast the value anymore if you use any, you cannot create a generic list to store interfaces, string, numbers, etc.. and then extract the values to continue working with them?
@sultansheikh6184
@sultansheikh6184 2 года назад
One of the best channel for go keep up bro 💪
@3r1c3
@3r1c3 2 года назад
Can someone plz tell me the name of this vscode theme? I love it
@MichalKoziatek
@MichalKoziatek 2 года назад
same! Really nice colours
@ThanhNguyen-kt8kj
@ThanhNguyen-kt8kj 2 года назад
What is the theme you use for vscode? Thank you so much.
@codelinx
@codelinx Год назад
Amazing content and explanations.
@mwat56
@mwat56 2 года назад
Why do I always hear "genetic" (instead of "generic")?
@katzenschildkroete
@katzenschildkroete 2 года назад
Ouelsh Akksent
@JonathanLoscalzo
@JonathanLoscalzo 2 года назад
Google translate too
@ScottKFraley
@ScottKFraley 2 года назад
Probably the Scotish accent. :)
@mirabbos02
@mirabbos02 2 года назад
Cool 👍
@mumk
@mumk 2 года назад
Thanks a lot for the sharing
@Somethingsomethinglol
@Somethingsomethinglol 2 года назад
Great explanation ty
@hidayathidayat4469
@hidayathidayat4469 2 года назад
hallo everyone. how people implement this without generic?
@LopestEmarq
@LopestEmarq 2 года назад
One function for each type (and yes, some code repetition)
@АлексейЗайцев-б7у
@АлексейЗайцев-б7у 2 года назад
Hi! What colorscheme do you use?
@usernameL1
@usernameL1 2 года назад
Would like to know as well!
@williamokano
@williamokano 2 года назад
Seems more like union types than generics itself
@Max-bh8tg
@Max-bh8tg 2 года назад
Using the "any" keyword will make it totally generic.
@williamokano
@williamokano 2 года назад
@@Max-bh8tg 😂
@TroenderTass
@TroenderTass 2 года назад
Well, i've got to say they finally gave people a reason to maybe use go. Up to now, the language has been completly useless
@oussamasethoum1665
@oussamasethoum1665 2 года назад
One of the best things you can do a video on is entgo + gqlgen for full backend with graphql
@ravi-mo6js
@ravi-mo6js 2 года назад
Eeeeexcellent, said Mr. Burns xD
@angrysmilex
@angrysmilex 2 года назад
Very clear explanation, thanks!
@champfisk5613
@champfisk5613 2 года назад
This is nice but I will wait for it to be released in stable
@Max-bh8tg
@Max-bh8tg 2 года назад
It's been released now!
@am_0x2a
@am_0x2a 2 года назад
What sweet VS Code theme is that?!
@shuaibolayinka7644
@shuaibolayinka7644 2 года назад
doest this work for custom types?
@Max-bh8tg
@Max-bh8tg 2 года назад
Yes it does
Далее
Beginner's Guide to Unit Test Logging in Go
3:55
Просмотров 1,2 тыс.
Understanding Contexts in Go in 5(-ish?) Minutes
15:14
Golang Channels Or Wait Groups? Let Me Explain.
18:32
Golang Generics. Do we ACTUALLY need them!?
12:51
Просмотров 19 тыс.
Advanced Golang: Generics Explained
13:37
Просмотров 64 тыс.
Learn Go Generics - everything you need to know
27:45
Golang Generics is Officially HERE!! (Full Tutorial)
13:31
Generics Unconstrained! - Roger Peppe
28:31
Просмотров 4,7 тыс.
Nix explained from the ground up
23:39
Просмотров 32 тыс.
Is Fiber the best Go web framework? Better than Gin?
21:07