I try to run examples from the design draft (The Next Step for Generics) on go2go.playground
type Pair(type T) struct { f1, f2 T }
, but get an error
prog.go2:14:11: expected type, found 'type' (and 1 more errors)
Where can I find actual go generics
design draft
?
You're looking at outdated design draft.
This one is current: https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md
So, it's not:
type Pair(type T) struct { f1, f2 T }
But:
type Pair[T any] struct { f1, f2 T }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With