I'm reading this repo unittest code and the Client
struct is created in a way that I never seen before.
type Client struct {
// client stuff
}
// In client_test.go
// Creating default client for testing
c := dc()
// In resty_test.go
func dc() *Client {
DefaultClient = New()
DefaultClient.SetLogger(ioutil.Discard)
return DefaultClient
}
My question is that what is the purpose of returning New()
?
Does the code below behave similarly as the New()
style? Why should choose one over another?
func dc() *Client {
DefaultClient := Client{}
return &DefaultClient
}