Blog

How to create an IPv6 request with Golang

on 10 Sep, 2020 by Julian Zander

Creating an IPv6 request is relatively simple
You have to create a http.client with a custom transport

You only have to replace the DialContext with tcp6

Code example:

webClient := http.Client{
    Transport: &http.Transport{
        Proxy: http.ProxyFromEnvironment,
        DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
            dialer := net.Dialer{}
            return dialer.DialContext(ctx, "tcp6", addr)
        },
        MaxIdleConns:          100,
        IdleConnTimeout:       90 * time.Second,
        TLSHandshakeTimeout:   10 * time.Second,
        Expe...
... Read more!



No categories were found.