go-http-dialer icon indicating copy to clipboard operation
go-http-dialer copied to clipboard

Not a drop in replacement

Open wheelerlaw opened this issue 6 years ago • 1 comments

Okay, to be fair, I am pretty new at Go, so pardon my naiveté.

I am trying to use http_dialer#New as a drop in replacement for a constructor that can accept a parameter of type *net.Dialer. However, when I use it, I get:

cannot use http_dialer.New(forwarder.Proxy, nil) (type *http_dialer.HttpTunnel) as type *net.Dialer in field value

I tried casting it (net.Dialer(*http_dialer.New(forwarder.Proxy, nil))), but I get:

cannot convert *http_dialer.New(forwarder.Proxy, nil) (type http_dialer.HttpTunnel) to type net.Dialer

wheelerlaw avatar Nov 27 '18 23:11 wheelerlaw

Okay, I think I am getting closer. I tried setting Dial of the client:

client.Dialer.Dial = http_dialer.New(
					forwarder.Proxy,
					http_dialer.WithDialer(client.Dialer),
				).Dial

where client is an instance of github.com/miekg/dns.Client

However, now I get:

cannot assign to client.Dialer.Dial

wheelerlaw avatar Nov 28 '18 00:11 wheelerlaw