Day: January 8, 2017

  • Golang: Testing HTTP requests

    Unit testing HTTP calls to external services is pretty easy in Go. Let’s say we have some code that makes HTTP requests like so: package something import ( “net/http” ) func SomeFunc(url) string { rs, _ := http.Get(url) defer rs.Body.Close() body, _ := ioutil.ReadAll(rs) return string(body) } We can test if the request is made…