localAddr, err := net.ResolveIPAddr("ip", "192.168.1.2")
if err != nil {
panic(err)
}
localTCPAddr := net.TCPAddr{
IP: localAddr.IP,
}
client := &http.Client{
Transport: &http.Transport{
Dial: (&net.Dialer{
LocalAddr: localTCPAddr,
}).Dial,
},
}