typeover
curriculum

Curriculum Interfaces & generics

module 4 of 7

Interfaces & generics

Structural typing in Go's shape — implicit satisfaction with no implements keyword. Then generics on top: familiar from TS, mostly syntax to learn.


themes

interface { Foo() }. A type implements an interface by having the right methods. There is no implements keyword. Satisfaction is implicit: if the methods match, the type sa…

9 ready begin →

Mostly familiar from TS. func Foo[T any](x T) T { ... }. The constraint syntax is where Go adds something new: an interface used as a constraint can list types or use ~T for "a…

9 ready begin →