Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go2go.playground - expected type, found 'type' (and 1 more errors)

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?

like image 339
kozmo Avatar asked Dec 31 '22 20:12

kozmo


1 Answers

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 }
like image 173
Z. Kosanovic Avatar answered Mar 15 '23 23:03

Z. Kosanovic