Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You don’t. Each consumer of something declares what it needs via an interface, something concrete may be passed that implements it - including fakes for tests.

Of course this doesn’t apply when using interfaces for polymorphic return types in a library, but that is a distinct use case for interfaces to address.

Perhaps some of this is just taste, but this is the way I’ve found interfaces in Go to be most useful.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: