November 2018
Intermediate to advanced
346 pages
8h 12m
English
1. How does monkey patching work?
At its most basic level, monkey patching in Go involves swapping out one variable for another at runtime. This variable can be an instance of the dependency (in the form of a struct) or a function that wraps access to the dependency.
At a higher level, monkey patching is about replacing or intercepting access to a dependency to replace it with another implementation, typically a stub or a mock, to make testing simpler.
2. What are the ideal use cases for monkey patching?
Monkey patching can be used in a variety of situations, but the most notable are the following:
Read now
Unlock full access