Let's say I have this function
func main() {
x := 10
change(&x)
}
func change(n *int) {
}
If I don't use in n *int the signature, the above function gives an error -
*cannot use &x (type int) as type int in argument to change
But why does the below example run fine without requiring a client *HTTPClient in the argument of send method though I'm passing a pointer in this case?
import (
"net/http"
)
// HTTPClient interface for making http requests
type HTTPClient interface {
Get(url string) (*http.Response, error)
}
func main() {
client := &http.Client{}
err := send(client, url)
}
func send(client HTTPClient, url string) error {
}