Please Use Dependency Injection, If Not For Me, Do It For Your Unit Tests
TLDR; see title. Long time no see, and it’s been a while since we haven’t talked about Go. I still love the language, I still use it on a daily basis, and today I feel like talking a bit about dependency injection. So hold on to your seats because it’s going to get boring very soon, or not we’ll see. What’s the problem? Take the following file. It has a Fetch function that takes base currency and a target currency, and it fetches the exchange rate between the two currencies by contacting an API that has that information in JSON format.