Don't use named return values just for one value, especially an error

Be consistent with the rest of the code
This commit is contained in:
Frank Denis 2019-12-09 16:59:02 +01:00
parent 3e32d38f29
commit 2d8fd40481
1 changed files with 7 additions and 7 deletions

View File

@ -246,20 +246,20 @@ func (xTransport *XTransport) resolveUsingResolver(proto, host string, resolver
}
// Return a cached entry, or resolve a name and update the cache
func (xTransport *XTransport) resolveWithCache(host string) (err error) {
err = nil
func (xTransport *XTransport) resolveWithCache(host string) error {
if xTransport.proxyDialer != nil || xTransport.httpProxyFunction != nil {
return
return nil
}
if ParseIP(host) != nil {
return
return nil
}
cachedIP, expired := xTransport.loadCachedIP(host)
if cachedIP != nil && !expired {
return
return nil
}
var foundIP net.IP
var ttl time.Duration
var err error
if !xTransport.ignoreSystemDNS {
foundIP, ttl, err = xTransport.resolveUsingSystem(host)
}
@ -292,12 +292,12 @@ func (xTransport *XTransport) resolveWithCache(host string) (err error) {
foundIP = cachedIP
ttl = ExpiredCachedIPGraceTTL
} else {
return
return err
}
}
xTransport.saveCachedIP(host, foundIP, ttl)
dlog.Debugf("[%s] IP address [%s] added to the cache, valid for %v", host, foundIP, ttl)
return
return nil
}
func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string, contentType string, body *[]byte, timeout time.Duration, padding *string) (*http.Response, time.Duration, error) {