According to the documentation, indeed the IP
type does not implement Addr
. However, the type IPAddr
does:
type IPAddr struct {
IP IP
Zone string // IPv6 scoped addressing zone
}
Therefore, your code becomes:
q := net.ParseIP("192.168.0.1")
addr := &net.IPAddr{q,""}
var transport = &http.Transport{
Dial: (&net.Dialer{
LocalAddr: addr,
}).Dial,
}