Fetching Private Go Modules During Docker Build

After many hours of struggling with getting my go application to build within the building of my docker image, I decided this information could be useful to others. The problem I experienced, and likely why you are reading this, is that in order to fetch go dependencies from a private repository you need to setup git credentials within the docker image build.

Here are some errors that I was seeing through my struggles:

go: github.com/jwenz723/privatepackage@v1.0.0: unknown revision v1.0.0
go: error loading module…