On Mon, Jan 24, 2022 at 9:02 AM 'Kaisa Lim' via golang-nuts < golang-nuts@googlegroups.com> wrote:
> 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? > > [image: 스크린샷 2022-01-24 오후 7.12.19.png] > > * Again, build and run is normal * > What IDE are you using? Generics are very new and are not yet in any released version of Go. Are you sure that your IDE supports generics? Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUQHjXA75iqf8yRsA76jZiJy582SbzbvuUPDz%3Dn%2BbtOQA%40mail.gmail.com.