Published in Level Up Coding·Oct 6, 2022Member-onlyMocking Outbound HTTP Calls in Golang — net/http/httptestA while back I wrote an article titled “Mocking Outbound HTTP Calls in Golang” which showed how to mock downstream HTTP calls using an HTTP interface. The goal was to showcase how you can test any of your code without making any actual HTTP calls. This method works wonderfully, but…Golang8 min readGolang8 min read
Published in Level Up Coding·Jun 23, 2022Member-onlyMulti-String Replace in Golang with ReplacerString replacements in Golang are very easy using the strings package. From their docs: “Package strings implements simple functions to manipulate UTF-8 encoded strings”. Take the following sentence: "Hello World!" Now let’s say my product owner thinks saying “Hello World” with an exclamation mark is just too much, and if…Golang3 min readGolang3 min read
Published in Level Up Coding·Dec 29, 2021Member-onlyTraining an ML.NET Image Classification Model on GPUs using Google ColabIf you’re an ML.NET user and looking to train your models on GPUs, you may find you have limited options that are easy to consume. If you happen to be on a desktop that can support Nvidia GPU graphics cards you're in luck! If you happen to be on a…Mlnet16 min readMlnet16 min read
Published in Level Up Coding·Oct 11, 2021Member-onlyEffective Debugging with .NET Core & Docker Compose (Launch Compose Stack on Debug Start in VS Code)Most of the projects I work with today have external dependencies of some sort. This could be a database, a cloud provider, or just another API that I need to talk to. It’s rare that I don’t have to communicate with something over a network in order to develop my…Docker Compose7 min readDocker Compose7 min read
Published in Level Up Coding·Sep 14, 2021Member-onlySharing Docker Images Without Docker HubRecently I was working on a side project and needed to switch over to another laptop to work. My project called for a Docker image that laptop #2, unfortunately, did not already have. I went to do a simple Docker pull and got the dreaded: Error response from daemon: Get…Docker4 min readDocker4 min read
Published in Level Up Coding·Jan 2, 2021Member-onlyCalling Multiple APIs Concurrently in Go (Goroutine and WaitGroup)With so many REST APIs floating around today, you’ll at some point find yourself in a situation where you need to call multiple endpoints to build a proper representation of your business object. This is not a difficult task, just create a new object, call the various APIs for data…Go5 min readGo5 min read
Published in Level Up Coding·Dec 31, 2020Member-onlyUnit Test SQL in Golang, Without Mocking, Using TestContainers (Go, Postgres, Docker, TestContainers)I wrote another article about this same topic which utilized a pure Docker solution to test database code without mocking. It was a cool solution, and worked really well, however it was a bit heavy-handed. It required special scripts, a certain folder structure, and could be hard to follow at…Testing11 min readTesting11 min read
Published in Level Up Coding·Dec 14, 2020Member-onlyMocking Outbound HTTP Calls in Golang — interfacesEngineers these days have so many cool APIs to work with. You can literally find an API for a particular need with only a Google search. We have Twilio for sending emails/faxes/text messages, The Rundown for real-time sports scores and odds, or Airbnb to manage your listings. …Golang10 min readGolang10 min read
Published in Level Up Coding·Dec 7, 2020Member-onlyUnit Test SQL in Golang, Without Mocking, Using Docker (Go, Postgres, Docker)UPDATE: I’ve written a companion article using TestContainers, based on a comment that I should look into that package. It accomplishes the same goal, testing database code without mocks. You can read it here: https://atkinsonbg.medium.com/unit-test-sql-in-golang-without-mocking-using-testcontainers-go-postgres-docker-4f61574b1989 Recently while working on an API that interfaced with a database, I mistakenly updated our…Docker16 min readDocker16 min read
Published in Level Up Coding·Nov 16, 2020Member-onlyDebugging Go Inside Docker, Using Visual Studio Code and Remote ContainersThere have been many times in my career or when working on personal projects, that I have needed some open-source executables to help me complete my task. I have used things like Weasyprint, WKHTMLTOPDF, Exiftool, Ghostscript, the list goes on and on (these are just some of the more recent…Docker8 min readDocker8 min read