TBH, anything that can make interface casting faster/more efficient in go would be a welcome improvement.
Surely that is wrong:
package satisfy
type I interface { foo(); }
type S1 struct { a int; }
type S2 struct { a int; }
func (s *S1) foo() { s.a = 1; }
var _ I = (*S1)(nil);
var _ I = (*S2)(nil);
Then we get: $ go build ./satisfy.go
# command-line-arguments
./satisfy.go:7:11: cannot use (*S2)(nil) (value of type *S2) as type I in variable declaration:
*S2 does not implement I (missing foo method) package defmeth
type I interface { foo(); }
type defs struct { }
func (s *defs) foo() { }
var _ I = (*defs)(nil);
type usage struct { defs; a int; }
var _ I = (*usage)(nil);
arp242•5mo ago
I do agree all of this can be quite painful, but I'm not so sure that default methods are the right solution.