func CreateSlice[T int | string](length int) []T {
return make([]T, length)
}
Try to learn go and want to play with slices and generics . Above you can see that I want to say T can be or int or string => T int | string . Compiler say nothing about this case when I create this function , but on the moment I call it , it says cannot infer T
slices.CreateSlice(10)
Is there any restriction , or do I make some mistaces in syntax ?