From d383fca08253f7903d6c0e00fd34c291a1fab2eb Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 8 Dec 2015 13:40:27 +0200 Subject: [PATCH] Made Dial and DialFunc more visible in the documentation --- tcpdialer.go | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tcpdialer.go b/tcpdialer.go index 3e65612..cea5df2 100644 --- a/tcpdialer.go +++ b/tcpdialer.go @@ -8,26 +8,44 @@ import ( "time" ) -// TCP dialers used by client. +var ( + dial = (&tcpDialer{}).NewDial() + dialDualStack = (&tcpDialer{DualStack: true}).NewDial() +) + +// Dial dials the given TCP addr using tcp4. // -// These dialers are intended for custom code wrapping before passing +// This dialer is intended for custom code wrapping before passing // to Client.Dial or HostClient.Dial. // // For instance, per-host counters and/or limits may be implemented // by such wrappers. // -// The addr passed to dial func must contain port. Example addr values: +// The addr passed to the function must contain port. Example addr values: // // * foobar.baz:443 // * foo.bar:80 // * aaa.com:8080 -var ( - // Dial dials the given addr using tcp4. - Dial = DialFunc((&tcpDialer{}).NewDial()) +func Dial(addr string) (net.Conn, error) { + return dial(addr) +} - // DialDualStack dials the given addr using both tcp4 and tcp6. - DialDualStack = DialFunc((&tcpDialer{DualStack: true}).NewDial()) -) +// DialDualStack dials the given TCP addr using both tcp4 and tcp6. +// +// This dialer is intended for custom code wrapping before passing +// to Client.Dial or HostClient.Dial. +// +// For instance, per-host counters and/or limits may be implemented +// by such wrappers. +// +// The addr passed to the function must contain port. Example addr values: +// +// * foobar.baz:443 +// * foo.bar:80 +// * aaa.com:8080 +func DialDualStack(addr string) (net.Conn, error) { + return dialDualStack(addr) +} type tcpDialer struct { DualStack bool