Generics in Go 1.18 - Introduced using a practical example

preview_player
Показать описание
In this talk, Axel Wagner is going to introduce Generics, one of the major features of Go 1.18. The talk makes use of a practical example to illustrate the real-world usefulness of Generics in Go.

00:00 Introduction generics in Go 1.18
01:40 Practical example
06:35 Problems
09:05 Generics (Type parameters, Type-inference)
16:30 Making call safe
26:20 Constraints
30:13 Type sets
38:15 Constraint package
39:21 Comparable
45:17 Pointer methods
52:48 Library changes
55:00 Limitations
Рекомендации по теме
Комментарии
Автор

Very good introduction to generics in Go.

kamilziemian
Автор

4:58 I have two questions. First, how package foo has access to structure `prov` defined in the package provider? I was thinking that type name must starts with capital letter to be exported?

Second is about method `func (p *prov) ID provider.ID`. It now has code `return ID` and I would expected something like `return p.ID`.

kamilziemian
Автор

I think the example is too advanced for introduction to generics in Go. Slice or sort operations with multiple types (int, float, ...) would be more understandble.

_shulhan