Documentation
¶
Index ¶
- Constants
- Variables
- func AppendfNoEscape(b []byte, format string, a ...any) []byte
- func BinaryReadNoEscape(r io.Reader, order binary.ByteOrder, data any) error
- func CanonicalUvarint(buf []byte) (uint64, int)
- func ContextTick(ctx context.Context, d time.Duration) <-chan time.Time
- func Debugf(prefix, format string, v ...any)
- func Div128(hi, lo, y uint64) (hiQuo, loQuo uint64)
- func Error(v ...any)
- func Errorf(prefix, format string, v ...any)
- func ErrorfNoEscape(format string, a ...any) error
- func Fatalf(format string, v ...any)
- func GetOutboundIPv6() ([]netip.Addr, error)
- func IsLogLevelDebug() bool
- 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 NextPowerOfTwo[T ~uint | ~uint64](x T) int
- func Noticef(prefix, format string, v ...any)
- func NthElementSlice[S ~[]E, E cmp.Ordered](s S, k int)
- func NthElementSliceFunc[S ~[]E, E any](s S, cmpFunc 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[T ~uint | ~uint64](x T) int
- func Print(v ...any)
- func ReadByteNoEscape(reader io.ByteReader) (byte, error)
- func ReadCanonicalUvarint(r io.ByteReader) (uint64, error)
- func ReadFullNoEscape(reader io.Reader, buf []byte) (n int, err error)
- func ReadFullProgressive[T ~[]byte](r io.Reader, dst *T, size int) (n int, err error)
- func ReadLittleEndianInteger[T ~uint8 | ~int8 | ~uint16 | ~int16 | ~uint32 | ~int32 | ~uint64 | ~int64](r io.Reader, x *T) (err error)
- func ReadNoEscape(reader io.Reader, buf []byte) (n int, err error)
- func ResetNoEscape(hasher hash.Hash)
- 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, ...) error
- func SprintfNoEscape(format string, a ...any) string
- func SumNoEscape(hasher hash.Hash, buf []byte) []byte
- func UVarInt64Size[T uint64 | int | uint8](v T) (n int)
- func UVarInt64SliceSize[T uint64 | int](v []T) (n int)
- func UnmarshalJSON(data []byte, val any) error
- func ValuesToPointers[T any, S ~[]T](x S) []*T
- func WriteNoEscape(writer io.Writer, buf []byte) (n int, err 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 JSONDecoder
- type JSONEncoder
- type LRUCache
- type LimitedByteReader
- type LogLevel
- type MapCache
- type NilCache
- type ReaderAndByteReader
- type Serializable
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 IFA_FLAGS = 0x8
const IsBigEndian = false
IsBigEndian records whether the GOARCH's byte order is big endian.
Variables ¶
var ErrNonCanonicalEncoding = errors.New("binary: varint has non canonical encoding")
var GOMAXPROCS = min(runtime.GOMAXPROCS(0), runtime.NumCPU())
var GlobalLogLevel = LogLevelError | LogLevelInfo
var LogFile bool
var LogFunc bool
Functions ¶
func BinaryReadNoEscape ¶
func CanonicalUvarint ¶
CanonicalUvarint decodes a uint64 from buf and returns that value and the number of bytes read (> 0). If an error occurred, the value is 0 and the number of bytes n is <= 0 meaning:
- n == 0: buf too small;
- n < 0: value larger than 64 bits (overflow) and -n is the number of bytes read.
The function errors if non-canonical bytes were read.
func ErrorfNoEscape ¶
func GetOutboundIPv6 ¶
func IsLogLevelDebug ¶
func IsLogLevelDebug() bool
func Keys ¶
func Keys[M ~map[K]V, K comparable, V any](m M) []K
func MarshalJSON ¶
func NetIPIsCGNAT ¶
func NextPowerOfTwo ¶
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 ReadByteNoEscape ¶
func ReadByteNoEscape(reader io.ByteReader) (byte, error)
func ReadCanonicalUvarint ¶
func ReadCanonicalUvarint(r io.ByteReader) (uint64, error)
ReadCanonicalUvarint reads an encoded unsigned integer from r and returns it as a uint64. The error is ErrNonCanonicalEncoding if non-canonical bytes were read. The error is io.EOF only if no bytes were read. If an io.EOF happens after reading some but not all the bytes, ReadCanonicalUvarint returns io.ErrUnexpectedEOF.
func ReadFullProgressive ¶
ReadFullProgressive Reads into buf up to size bytes by doubling size each time
func ReadLittleEndianInteger ¶ added in v5.0.3
func ReadLittleEndianInteger[T ~uint8 | ~int8 | ~uint16 | ~int16 | ~uint32 | ~int32 | ~uint64 | ~int64](r io.Reader, x *T) (err error)
ReadLittleEndianInteger Reads a defined Integer type that has a defined size. Does not support reading int/uint types.
func ResetNoEscape ¶
func SliceCount ¶
func SprintfNoEscape ¶
func UVarInt64SliceSize ¶
func UnmarshalJSON ¶
func ValuesToPointers ¶ added in v5.0.3
func ValuesToPointers[T any, S ~[]T](x S) []*T
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 JSONDecoder ¶ added in v5.0.4
func NewJSONDecoder ¶
func NewJSONDecoder(reader io.Reader) *JSONDecoder
type JSONEncoder ¶ added in v5.0.4
func NewJSONEncoder ¶
func NewJSONEncoder(writer io.Writer) *JSONEncoder
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 NilCache ¶
type NilCache[K comparable, T any] struct { }
func NewNilCache ¶
func NewNilCache[K comparable, T any]() NilCache[K, T]
type ReaderAndByteReader ¶
type ReaderAndByteReader interface {
io.Reader
io.ByteReader
}