github.com/AndrienkoAleksandr/go@v0.0.19/src/go/doc/testdata/examples/generic_constraints.golden (about) 1 -- .Play -- 2 package main 3 4 import ( 5 "fmt" 6 ) 7 8 func main() { 9 fmt.Println("hello") 10 } 11 -- Generic.Play -- 12 package main 13 14 import ( 15 "fmt" 16 "time" 17 ) 18 19 type C1 interface { 20 string | int 21 } 22 23 type C2 interface { 24 M(time.Time) 25 } 26 27 type G[T C1] int 28 29 func g[T C2](x T) {} 30 31 type Tm int 32 33 func (Tm) M(time.Time) {} 34 35 func main() { 36 var x G[string] 37 g(Tm(3)) 38 fmt.Println(x) 39 }