title: How to mock http.Client Do method
body: <p>I'm trying to find a solution to write test and mock HTTP response.
  In my function where I accept interface:</p>
  
  <pre><code>type HttpClient interface {
      Do(req *http.Request) (*http.Response, error)
  }
  </code></pre>
  
  <p>I makes http get request with base auth</p>
  
  <pre><code>func GetOverview(client HttpClient, overview *Overview) (*Overview, error) {
  
      request, err := http.NewRequest("GET", fmt.Sprintf("%s:%s/api/overview", overview.Config.Url, overview.Config.Port), nil)
      if (err != nil) {
          log.Println(err)
      }
      request.SetBasicAuth(overview.Config.User, overview.Config.Password)
      resp, err := client.Do(request)
  </code></pre>
  
  <p>How can I mock this HttpClient?
  I'm looking for mock library, for instance: <a href="https://github.com/h2non/gock" rel="noreferrer">https://github.com/h2non/gock</a>
  but there is only mock for Get and Post</p>
  
  <p>Maybe I should do it in a different way.
  I'll be grateful for advice</p>