util

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPrefix              = "ZDNS"
	DefaultFilePermissions = 0644 // rw-r--r--
	DefaultDNSPort         = "53"
	DefaultHTTPSPort       = "443"
	DefaultTLSPort         = "853"
	InvalidPortErrorMsg    = "invalid port"
)

Variables

This section is empty.

Functions

func Concat

func Concat[S ~[]E, E any](slices ...S) S

Concat returns a new slice concatenating the passed in slices.

Avoids a gotcha in Go where since append modifies the underlying memory of the input slice, doing newSlice := append(slice1, slice2) can modify slice1. See https://go.dev/doc/effective_go#append A std. library concat was added in go 1.22, but this is for backwards compatibility. https://pkg.go.dev/slices#Concat This is mostly similiar to the std. library concat, but with a few differences so it compiles on go 1.20.

func Contains

func Contains[T comparable](slice []T, entity T) bool

Contains checks if a value is in a slice. Performance note: if you're going to be making multiple calls to Contains, it is much more performant to create a map of the slice to get O(1) lookups. This is for one-off lookups.

func HasCtxExpired

func HasCtxExpired(ctx context.Context) bool

HasCtxExpired checks if the context has expired. Common function used in various places.

func IsIPv6

func IsIPv6(ip *net.IP) bool

IsIPv6 checks if the given IP address is an IPv6 address.

func IsStringValidDomainName

func IsStringValidDomainName(domain string) bool

IsStringValidDomainName checks if the given string is a valid domain name using regex

func SplitHostPort

func SplitHostPort(inaddr string) (net.IP, int, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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