I have the following code. I'm getting this error:
testdl.go:17: cannot use q (type net.IP) as type net.Addr in field value: net.IP does not implement net.Addr (missing Network method)
Any idea how to put a hardcoded IP into LocalAddr?
package main
import (
"fmt"
"net"
"net/http"
)
var url = "http://URL/api.xml"
func main() {
q := net.ParseIP("192.168.0.1")
var transport = &http.Transport{
Dial: (&net.Dialer{
LocalAddr: q,
}).Dial,
}
var httpclient = &http.Client{
Transport: transport,
}
response, err := httpclient.Get(url)
fmt.Println(response)
}