The adapter pattern in Go
How do you test a database without a database? Don't worry, this isn't one of those Zen puzzles. I have something more practical, but equally enlightening, in mind. Let’s use the adapter pattern to solve the riddle.
How do you test a database without a database? Don't worry, this isn't one of those Zen puzzles. I have something more practical, but equally enlightening, in mind. Let’s use the adapter pattern to solve the riddle.
Sometimes you need to check the equality of two structs in Go, and depending on how complicated they are, you probably want to avoid hand-writing the Equal method if possible, and you want to avoid reflect.DeepEqual for performance reasons, at least in your production code. If I...
Introduction In episode 8, Miki developed a Go HTTP client that had a method to check the health of a theoretical API. The method would construct the request URL and return an error based on the response code received from the server. Miki then created a type that would mock Go�...
Introduction In episode 7, Miki discussed design considerations to keep in mind while creating interfaces in Go with the first idea he proposed being that an interface should represent what we need from a type, and not what is stored on the type. To add some clarity to this thoug...
I was on episode 269 of the Go Time podcast, talking about the bits of Go we avoid (and why). Check it out!
To celebrate the first anniversary of generics in Go, let’s build something practical and useful: a generic Set type, and add some neat methods to it. Ready for fun?
Introduction In episode 6, Miki built a logger package with the aim of making it as versatile as possible. To achieve this, he constructed his logger object with a function that would: accept the io.Writer interface as a parameter and perform type assertions to retrieve other int...
As written about in Automating boilerplate/scaffolding code with custom code generation in Go, being able to take advantage of generating Go code can be super handy. However, you may get to the point where you're working with the codegen that you find working with text-based temp...
Sometimes when you're integrating with APIs or web services, you need to debug the HTTP requests/responses that are occuring. In some toolchains it's part of configuration, but in Go it's unfortunately not part of the standard library to globally turn on logging for the http.Clie...