On a later page, the author writes “Before running the tests, delete the file .todo.json if it exists from a previous test or the test execution will fail” (page 26).
In order to avoid this problem and to save readers trouble, I suggest adding the following to the top of TestMain
:
// Let’s make sure we are not in a bad state: remove any cruft first.
os.Remove(binName)
os.Remove(fileName)
This way, the test runner cleans up any old binary or leftover .todo.json
files before a new binary is created or any tests run. This protects users from broken tests due to carelessness if they forget to remove an old file.