To give a bit of context as to what I am talking about, here is how the NewClient function looks like:
// NewClient returns a new mastodon API client.
func NewClient(config *Config) *Client {
return &Client{
Client: *http.DefaultClient,
Config: config,
}
}
While I could possibly understand the concerns (prevent mutability, etc), it breaks the expected semantic. http.Client is a pointer type (as it can be seen by http.DefaultHTTPClient). Even though a copy by value is perfectly OK for now, you may never know if it won't hold a mutex or something similar in the future that would turn making a copy into a bug.
To give a bit of context as to what I am talking about, here is how the
NewClient
function looks like:While I could possibly understand the concerns (prevent mutability, etc), it breaks the expected semantic.
http.Client
is a pointer type (as it can be seen byhttp.DefaultHTTPClient
). Even though a copy by value is perfectly OK for now, you may never know if it won't hold a mutex or something similar in the future that would turn making a copy into a bug.