matryer/goblueprints

chapter4/thesaurus/thesaurus.go - interface not used?

Closed this issue · 3 comments

The interface, Thesaurus, we create in Chapter 4 does not seem to be used in the rest of the code?

If I haven't missed something how would the code change if we did require this interface?

I think I need a little more explanation here please.

It's more the idea of describing an interface, which we then provide the first (or default) implementation of. But it would let others (outside the code) contribute their own implementations, and they wouldn't be forced to use ours.

Thanks Mat,that is pretty much what you said in the book. Are you saying that the interface would never get used in the code and that it is just a guide to future users?

Yeah, and you might well decide not to do this. Instead, you could provide a concrete type and let other users write an interface that fits if they need it. As an extra exercise, you could try writing a test implementation that doesn't use a real web service?