Documentation ¶
Index ¶
- Constants
- Variables
- func ContextTick(ctx context.Context, d time.Duration) <-chan time.Time
- func Debugf(format string, v ...any)
- func DecodeBinaryNumber(i string) uint64
- func DecodeHexBinaryNumber(i string) string
- func EncodeBinaryNumber(n uint64) string
- func EncodeHexBinaryNumber(v2 string) string
- func EncodeSliceBinaryNumber(dst, src []byte) []byte
- func Error(v ...any)
- func Errorf(prefix, format string, v ...any)
- func Factorial(n uint64) (result uint64)
- func Fatalf(format string, v ...any)
- func GetOutboundIPv6() ([]netip.Addr, error)
- func Keys[M ~map[K]V, K comparable, V any](m M) []K
- func Logf(prefix, format string, v ...any)
- func MarshalJSON(val any) ([]byte, error)
- func MarshalJSONIndent(val any, indent string) ([]byte, error)
- func NetIPGetEUI48Information(addr netip.Addr)
- func NetIPIsCGNAT(addr netip.Addr) bool
- func NewJSONDecoder(reader io.Reader) *gojson.Decoder
- func NewJSONEncoder(writer io.Writer) *gojson.Encoder
- func Noticef(format string, v ...any)
- func NthElementSlice[S ~[]E, E cmp.Ordered](s S, k int)
- func NthElementSliceFunc[S ~[]E, E any](s S, cmp func(a, b E) int, k int)
- func Panic(v ...any)
- func Panicf(format string, v ...any)
- func ParseUint64(s []byte) (uint64, error)
- func PreviousPowerOfTwo(x uint64) int
- func Print(v ...any)
- func ProbabilityEffort(effort float64) float64
- func ProbabilityMode(i ...float64) (n float64)
- func ProbabilityNShares(shares uint64, effort float64) float64
- func Shorten(value string, n int) string
- func ShortenSlice(value []byte, n int) []byte
- func SiUnits(number float64, decimals int) string
- func SliceCount[S ~[]E, E any](s S, f func(E) bool) (count int)
- func SplitWork(routines int, workSize uint64, ...) bool
- func UVarInt64Size[T uint64 | int](v T) (n int)
- func UVarInt64SliceSize[T uint64 | int](v []T) (n int)
- func UnmarshalJSON(data []byte, val any) error
- func XMRUnits(v uint64) string
- func XorShift64Star(x uint64) uint64
- type Cache
- type CircularBuffer
- func (b *CircularBuffer[T]) Current() T
- func (b *CircularBuffer[T]) Exists(value T) bool
- func (b *CircularBuffer[T]) Get(index uint32) T
- func (b *CircularBuffer[T]) Push(value T)
- func (b *CircularBuffer[T]) PushUnique(value T) bool
- func (b *CircularBuffer[T]) Replace(value, replace T)
- func (b *CircularBuffer[T]) Reverse()
- func (b *CircularBuffer[T]) Slice() []T
- type ExtendedIPFlags
- type ExtendedIPNet
- type LRUCache
- type LimitedByteReader
- type LogLevel
- type MapCache
- type ReaderAndByteReader
Constants ¶
const ( LogLevelError = LogLevel(1 << iota) LogLevelInfo LogLevelNotice LogLevelDebug )
const ( IFA_F_SECONDARY = 0x01 IFA_F_TEMPORARY = IFA_F_SECONDARY IFA_F_NODAD = 0x02 IFA_F_OPTIMISTIC = 0x04 IFA_F_DADFAILED = 0x08 IFA_F_HOMEADDRESS = 0x10 IFA_F_DEPRECATED = 0x20 IFA_F_TENTATIVE = 0x40 IFA_F_PERMANENT = 0x80 IFA_F_MANAGETEMPADDR = 0x100 IFA_F_NOPREFIXROUTE = 0x200 IFA_F_MCAUTOJOIN = 0x400 )
const ( VarIntLen1 uint64 = 1 << ((iota + 1) * 7) VarIntLen2 VarIntLen3 VarIntLen4 VarIntLen5 VarIntLen6 VarIntLen7 VarIntLen8 VarIntLen9 )
const IFA_FLAGS = 0x8
Variables ¶
var GlobalLogLevel = LogLevelError | LogLevelInfo
var JsonEncodeOptions = []gojson.EncodeOptionFunc{gojson.DisableHTMLEscape(), gojson.DisableNormalizeUTF8()}
var LogFile bool
var LogFunc bool
Functions ¶
func DecodeBinaryNumber ¶
func DecodeHexBinaryNumber ¶
func EncodeBinaryNumber ¶
func EncodeHexBinaryNumber ¶
func EncodeSliceBinaryNumber ¶
func GetOutboundIPv6 ¶
func Keys ¶
func Keys[M ~map[K]V, K comparable, V any](m M) []K
func MarshalJSON ¶
func NetIPIsCGNAT ¶
func NthElementSlice ¶
NthElementSlice QuickSelect implementation k is the desired index value, where array[k] is the k+1 smallest element values between s[0, k-1] are guaranteed <= to s[k] values between s[k+1, len(s)] are guaranteed >= to s[k]
func NthElementSliceFunc ¶
NthElementSliceFunc QuickSelect implementation k is the desired index value, where array[k] is the k+1 smallest element values between s[0, k-1] are guaranteed <= to s[k] values between s[k+1, len(s)] are guaranteed >= to s[k]
func ParseUint64 ¶
ParseUint64 parses uint64 from s.
It is equivalent to strconv.ParseUint(s, 10, 64), but is faster.
func PreviousPowerOfTwo ¶
func ProbabilityEffort ¶
func ProbabilityMode ¶
func ProbabilityNShares ¶
func ShortenSlice ¶
func SliceCount ¶
func UVarInt64Size ¶
func UVarInt64SliceSize ¶
func UnmarshalJSON ¶
func XorShift64Star ¶
XorShift64Star Implementation of xorshift* https://en.wikipedia.org/wiki/Xorshift#xorshift* x must be initialized to a non-zero value
Types ¶
type Cache ¶
type Cache[K comparable, T any] interface { Get(key K) (value T, ok bool) Set(key K, value T) Delete(key K) Clear() Stats() (hits, misses uint64) }
type CircularBuffer ¶
type CircularBuffer[T comparable] struct { // contains filtered or unexported fields }
func NewCircularBuffer ¶
func NewCircularBuffer[T comparable](size int) *CircularBuffer[T]
func (*CircularBuffer[T]) Current ¶
func (b *CircularBuffer[T]) Current() T
func (*CircularBuffer[T]) Exists ¶
func (b *CircularBuffer[T]) Exists(value T) bool
func (*CircularBuffer[T]) Get ¶
func (b *CircularBuffer[T]) Get(index uint32) T
func (*CircularBuffer[T]) Push ¶
func (b *CircularBuffer[T]) Push(value T)
func (*CircularBuffer[T]) PushUnique ¶
func (b *CircularBuffer[T]) PushUnique(value T) bool
func (*CircularBuffer[T]) Replace ¶
func (b *CircularBuffer[T]) Replace(value, replace T)
func (*CircularBuffer[T]) Reverse ¶
func (b *CircularBuffer[T]) Reverse()
func (*CircularBuffer[T]) Slice ¶
func (b *CircularBuffer[T]) Slice() []T
type ExtendedIPFlags ¶
type ExtendedIPFlags uint
const ( FlagTemporary ExtendedIPFlags = 1 << iota FlagPermanent FlagNoPrefixRoute FlagManageTempAddress FlagStablePrivacy FlagDeprecated )
type ExtendedIPNet ¶
type ExtendedIPNet struct { IP net.IP // network number Mask net.IPMask // network mask Flags ExtendedIPFlags }
func InterfaceAddrs ¶
func InterfaceAddrs(ifi *net.Interface) ([]*ExtendedIPNet, error)
InterfaceAddrs returns a list of unicast interface addresses for a specific interface.
func (*ExtendedIPNet) String ¶
func (n *ExtendedIPNet) String() string
type LRUCache ¶
type LRUCache[K comparable, T any] struct { // contains filtered or unexported fields }
func NewLRUCache ¶
func NewLRUCache[K comparable, T any](size int) *LRUCache[K, T]
type LimitedByteReader ¶
type LimitedByteReader struct { R ReaderAndByteReader // underlying reader N int64 // max bytes remaining }
A LimitedByteReader reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining. Read returns EOF when N <= 0 or when the underlying R returns EOF.
func LimitByteReader ¶
func LimitByteReader(r ReaderAndByteReader, n int64) *LimitedByteReader
LimitByteReader returns a Reader that reads from r but stops with EOF after n bytes. The underlying implementation is a *LimitedReader.
func (*LimitedByteReader) Left ¶
func (l *LimitedByteReader) Left() int64
func (*LimitedByteReader) ReadByte ¶
func (l *LimitedByteReader) ReadByte() (v byte, err error)
type MapCache ¶
type MapCache[K comparable, T any] struct { // contains filtered or unexported fields }
func NewMapCache ¶
func NewMapCache[K comparable, T any](preAllocateSize int) *MapCache[K, T]
type ReaderAndByteReader ¶
type ReaderAndByteReader interface { io.Reader io.ByteReader }