Field access in generic

why field access doesn’t work in generic?

I get error : ‘User’ redeclared in this package

type entities interface {
	type User, Customer
}

type User struct {
	ID int64
	Name string
	Email string
}

type Customer struct {
	ID int64
	Name string
	Email string
}

func Insert[T entities](entry T) (T, error) {
	
}

Hi @Ja7ad,

Welcome to the forum.

The line “type User, Customer” is invalid syntax and would trigger a syntax error rather than the error that you describe.

Can you share the code that produces the error message that you observe? Maybe via the Go Playground.

Please check this : Go Playground - The Go Programming Language
I following Ultimate Go Notebook by william kennedy

Just like @christophberger said, the compiler reports a syntax error: syntax error: unexpected type, expecting method or embedded element. You can replace the type User, Customer within your entities with User | Costumer, but then you run into this https://github.com/golang/go/issues/48522