Unit test with HTTP client in Go

Introduction In this post we will explore an example of how to test code with unit test that uses an HTTP client. Code with HTTP Client The following code is a typical example of a function that uses an HTTP client to do some requests. package main import ( 'context' 'errors' 'fmt' 'io' 'log' 'net/http' 'strings' ) var ( ErrFailedToCreateRequest = errors . New ( 'failed to create request' )…