You'll want to check out `gomock` and `mockgen`. You'll need to write an
interface to be able to mock, so you may need to write a receiver struct to
encapsulate os.Hostname() or whatever you need to mock, then mock your
HostnameGetter (surely a better name than that), maybe?
type OsClient
You'll want to look into gomock and mockgen. To get started mocking,
you'll need an interface, so maybe writing a receiver function
encapsulating os.Hostname(), then consuming that with an interface.
type OsClient struct {}
func (o *OsClient) GetOSHostname() (string, error) { return
-5, Burak Serdar wrote:
>
> On Wed, Oct 17, 2018 at 10:30 AM Kyle Butz > wrote:
> >
> > Hi All!
> >
> > I'm having trouble understanding whether a new http.Client{} with no
> Transport set will use a new copy of DefaultTransport, or the global?
> &
Hi All!
I'm having trouble understanding whether a new http.Client{} with no
Transport set will use a new copy of DefaultTransport, or the global?
>From client.go:
func (c *Client) transport() RoundTripper {
if c.Transport != nil {
return c.Transport
}
return DefaultTransport
}