Question: Consider the experimental package slices. The package is experimental, so I understand the signatures may change; I’m using it to illustrate the issue. Consider the signatures of two functions from this package, slices.Contains and slices.Grow: func Contains[E comparable](s []E, ...

Question: why the Number slice a couldn’t be initialized like that? NumberSlice and NNumberSlice look like similarly, but what mean type constraints, it looks strange grammar Answer: The language specifications explicitly disallow using interfaces with type elements as anything other ...

Question: I’m trying out go generics in 1.18beta2 and I’m trying to write an abstraction layer for key/value store, boltdb. This is what I’m trying to achieve with it. So that I can provide it a factory to create the ...

Question: In the following code I have a token type that contains a literal value. By using an empty interface I can create a slice of tokens and append tokens that have different types. I don’t think it’s possible to ...