How to mark golang struct as implementing interface?

In Go, implementing an interface is implicit. There is no need to explicitly mark it as implementing the interface. Though it’s a bit different, you can use assignment to test if a type implements an interface and it will produce a compile time error if it does not. It looks like this (example from Go’s FAQ page);

type T struct{}
var _ I = T{}       // Verify that T implements I.
var _ I = (*T)(nil) // Verify that *T implements I.

To answer your second question, yes that is saying your struct is composed of a type which implements that interface.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)