Help us shape the future of Go! Take the 2026 Go Developer Survey

dns

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearCache added in v1.0.0

func ClearCache()

ClearCache removes all entries from the DNS cache.

func ClearHost added in v1.0.0

func ClearHost(host string)

ClearHost removes all cached entries for the given hostname (both ipv4 and ipv6 keys).

func DefaultConfig

func DefaultConfig() (*dns.ClientConfig, error)

DefaultConfig get the local dns server with better Linux distribution compatibility

func DialContext

func DialContext() func(ctx context.Context, network, addr string) (net.Conn, error)

DialContext return a DialContext function for http.Transport, using the local resolver

func DialContextAt

func DialContextAt(servers []string, host string) func(ctx context.Context, network, addr string) (net.Conn, error)

DialContextAt return a DialContext function for http.Transport, using the given resolvers

func LookupIP

func LookupIP(host string, ipv6 ...bool) ([]string, error)

LookupIP looks up host using the local resolver. It returns a slice of that host's IPv4 and IPv6 addresses.

func LookupIPAt

func LookupIPAt(servers []string, host string, ipv6 ...bool) ([]string, error)

LookupIPAt looks up host using the given resolvers. It returns a slice of that host's IPv4 and IPv6 addresses.

func SetCacheForTest added in v1.0.0

func SetCacheForTest(key string, ips []string, expireAt time.Time)

SetCacheForTest injects entries into the DNS cache with a custom expiration (test-only).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL