So, earlier this year I had an idea to get a dragon tattoo, this such a cliché but, hear me out… The year of 2024, is the dragon tattoo in Chinese culture, and me, I was born on the year 2000. Yup, I am a gold dragon, well maybe not chinese, but still a dragon, lol.
The article discusses how to test a function that calls a dependency in other goroutines, which can make the test inconsistent. To solve this problem, the author suggests using Go’s sync.WaitGroup and GoMock’s .Do method. The article provides sample code for testing a service using these methods.
This article explains how to use GoMock, a mocking framework for the Go programming language, to mock external dependencies in order to facilitate unit testing. The article provides step-by-step instructions for generating a mock instance of an interface using GoMock, as well as an example test function that uses the mock to test the behavior of a service layer.
The errgroup package is a Go library that makes it easy to run a bunch of tasks concurrently and then cry in despair if any of them fail. So don’t let concurrent tasks ruin your day anymore, give the errgroup package a try and enjoy the peace of mind that comes with knowing that your tasks are being managed and your errors are being caught.
Breaking down the three laws of TDD.