Before the question, I'm sorry I'm not good at English
when go 1.18 beta released, i try to test generic type
Most of the code worked, but something went wrong when implementing the generic interface.
This is my code >
type Repository[T any] interface {
Save(T) T
}
type repo[T any] struct {
}
func NewRepository[T any]() Repository[T] {
return &repo[T]{}
}
func (r repo[T]) Save(entity T) T {
return entity
}
This code looks fine and works normally when executed.
But, ide throw compile exception. Why?
* Again, build and run is normal *