Hacker News new | ask | show | jobs
by nothrabannosir 3845 days ago
A pattern that helps with this (tangentially) is to explicitly declare methods to implement an interface at type declaration time:

    type File struct {
        ...
    }
    
    var _ io.Writer = (*File)(nil)
It's not a panacea, but it helps. If you write all your own code this way, at least it will be easy to see which interfaces your own types implement, and (with a grep or GoRef) vice versa.

Plus you get interface implementation checking, so your error messages actually make sense if the interface or type method signatures unexpectedly change.

Again, this is not a real solution to your problem, but it has enough advantages to be worth mentioning.