The delightful golang's interface matching seems to only go one layer deep. It matches the concrete structs (or their pointers) to interfaces as they are presented, but, if they are wrapped in anything, matching fails.
This also affects channels: the types of values they pass are not eligible for interface compatibility checks.
Minimal illustration:
type I0 interface{ fn0() }
type I1 interface{ fn1() I0 }
type S0 struct{}
func (s *S0) fn0() {}
type S1 struct{}
func (s *S1) fn1() *S0 { return &S0{} }
Now in this trivial example it's possible to just adapt S1
's fn1
return type, but I'd like to later use a type switch to recover original type without invoking the function.
The function case is mentioned in Go's FAQ as covariant result types.