Have you ever struggled when trying to test code that calls out to an external process and then uses the output as part of the implemented business logic? In some cases, it might be possible to use some of the tricks we have discussed so far to decorate our code with hooks that tests can use to mock the executed command's output. Unfortunately, sometimes this will not be possible. For instance, the code under test could import a third-party package that is actually the one that's responsible for executing some external command.
The Chapter04/pinger package exports a function called RoundtripTime. Its job is to calculate the round-trip time for reaching a remote ...