Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DialContext function #16

Closed
stokito opened this issue Oct 14, 2021 · 1 comment
Closed

DialContext function #16

stokito opened this issue Oct 14, 2021 · 1 comment

Comments

@stokito
Copy link

stokito commented Oct 14, 2021

It would be great to add the code snippet from docs into library itself and cover with a test:

    DialContext: func(ctx context.Context, network string, addr string) (conn net.Conn, err error) {
        host, port, err := net.SplitHostPort(addr)
        if err != nil {
            return nil, err
        }
        ips, err := r.LookupHost(ctx, host)
        if err != nil {
            return nil, err
        }
        for _, ip := range ips {
            var dialer net.Dialer
            conn, err = dialer.DialContext(ctx, network, net.JoinHostPort(ip, port))
            if err == nil {
                break
            }
        }
        return
    },

So users may just use it direcly instead of copying from docs.

@stokito
Copy link
Author

stokito commented Oct 17, 2021

created a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant