Writing good unit tests is made much easier by dependency injection. This lets you separate your code’s behavior from that of your dependencies.
Many people use mocks to add dependencies to unit tests. I think this is usually a mistake.
Writing good unit tests is made much easier by dependency injection. This lets you separate your code’s behavior from that of your dependencies.
Many people use mocks to add dependencies to unit tests. I think this is usually a mistake.
reflect
This article was originally published on gopheradvent.com
reflect
can be intimidating to new Go programmers because it’s very generic and you lose access to many niceties in the language. But it doesn’t have to be. Let’s build some programs that use reflect
as a way to demystify the package and illustrate the power and pitfalls that come with using it.