utils

package module
v0.0.0-...-0394936 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DNSTimeout = 100 * time.Millisecond

Variables

This section is empty.

Functions

func All

func All[T any](val []T, fn func(x T) bool) bool

func Any

func Any[T any](val []T, fn func(x T) bool) bool

func DNSLookup

func DNSLookup(ip string) string

func DNSResolve

func DNSResolve(url string) []string

func DeepCopy

func DeepCopy[T any](src T) *T

func First

func First[T any](in []T) T

func GetFile

func GetFile(url string) ([]byte, error)

func GetOutboundIP

func GetOutboundIP() string

Get preferred outbound ip of this machine

func LocalIP

func LocalIP() string

LocalIP returns the non loopback local IP of the host

func Must

func Must[T any](out T, err error) T

func PanicHandler

func PanicHandler() error

func PanicOnNil

func PanicOnNil(v any)

func PathExists

func PathExists(path string) bool

func RequestIP

func RequestIP(r *http.Request) string

func Ternary

func Ternary[T any](cond bool, t, f T) T

func WaitWithTimeout

func WaitWithTimeout(wg *sync.WaitGroup, timeout time.Duration) error

WaitWithTimeout waits for the waitgroup for the specified max timeout. Returns error if waiting timed out.

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

func (*Lock) Lock

func (l *Lock) Lock()

func (*Lock) RLock

func (l *Lock) RLock()

func (*Lock) RUnlock

func (l *Lock) RUnlock()

func (*Lock) Unlock

func (l *Lock) Unlock()

type Pool

type Pool[T any] struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool[T any](size int, objs ...T) *Pool[T]

func (*Pool[T]) Add

func (p *Pool[T]) Add(v T)

func (*Pool[T]) Get

func (p *Pool[T]) Get() T

func (*Pool[T]) Len

func (p *Pool[T]) Len() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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