utils

package
v0.0.0-...-b8a1a0e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

reference: https://my.oschina.net/ifraincoat/blog/604415

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APHash

func APHash(base uint64, str string) uint64

func Abs

func Abs(n time.Duration) time.Duration

func BKDRHash

func BKDRHash(base uint64, str string) uint64

func Bool2Int

func Bool2Int(b bool) int

func Bool2UInt32

func Bool2UInt32(b bool) uint32

func Bool2UInt8

func Bool2UInt8(b bool) uint8

func DJBHash

func DJBHash(base uint64, str string) uint64

func FindInterfaceByIp

func FindInterfaceByIp(ip string) *net.Interface

func GetIpHash

func GetIpHash(ip net.IP) uint32

func GetTraceIdIndex

func GetTraceIdIndex(traceId string, indexTypeIsIncremetalId, formatIsHex bool, incremetalIdStart, incremetalIdLength int) (uint64, error)

func IPv4ToBinary

func IPv4ToBinary(ip uint32) string

func IPv6ToBinary

func IPv6ToBinary(ip net.IP) string

func IpFromUint32

func IpFromUint32(ipInt uint32) net.IP

func IpNetmaskFromStringCIDR

func IpNetmaskFromStringCIDR(ipStr string) (net.IP, uint32, error)

func IpToUint32

func IpToUint32(ip net.IP) uint32

func IsMulticast

func IsMulticast(mac []byte) bool

func Mac2Uint64

func Mac2Uint64(mac net.HardwareAddr) uint64

func MaskLenToNetmask

func MaskLenToNetmask(mask uint32) uint32

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func Mountpoint

func Mountpoint(path string) string

找出目录对应的mount路径,来自: https://stackoverflow.com/questions/4453602/how-to-find-the-mountpoint-a-file-resides-on

func MurmurHashAdd

func MurmurHashAdd(hash, data uint32) uint32

func MurmurHashAddUint64

func MurmurHashAddUint64(hash uint32, data uint64) uint32

func MurmurHashFinish

func MurmurHashFinish(hash uint32) uint32

func ParserStringIp

func ParserStringIp(ipStr string) net.IP

func ParserStringIpV4

func ParserStringIpV4(ipStr string) net.IP

func PseudoCloneByteBuffer

func PseudoCloneByteBuffer(bytes *ByteBuffer)

func ReleaseByteBuffer

func ReleaseByteBuffer(bytes *ByteBuffer)

func SDBMHash

func SDBMHash(base uint64, str string) uint64

func Slice

func Slice(s string) (b []byte)

func String

func String(b []byte) (s string)

func Uint64ToMac

func Uint64ToMac(v uint64) net.HardwareAddr

func UintMin

func UintMin(x, y uint) uint

Types

type ByteBuffer

type ByteBuffer struct {
	pool.ReferenceCount // for PseudoClone
	// contains filtered or unexported fields
}

func AcquireByteBuffer

func AcquireByteBuffer() *ByteBuffer

func CloneByteBuffer

func CloneByteBuffer(bytes *ByteBuffer) *ByteBuffer

func (*ByteBuffer) Bytes

func (b *ByteBuffer) Bytes() []byte

返回所有Use调用过的[]byte

func (*ByteBuffer) Reset

func (b *ByteBuffer) Reset()

func (*ByteBuffer) SetQuota

func (b *ByteBuffer) SetQuota(n int)

func (*ByteBuffer) Use

func (b *ByteBuffer) Use(n int) []byte

返回下一个可用的[]byte,自动增长空间

type Closable

type Closable bool

func (*Closable) Close

func (c *Closable) Close() error

func (*Closable) Closed

func (c *Closable) Closed() bool

type IntBuffer

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

func (*IntBuffer) Reset

func (b *IntBuffer) Reset()

func (*IntBuffer) String

func (b *IntBuffer) String() string

func (*IntBuffer) WriteString

func (b *IntBuffer) WriteString(v string)

func (*IntBuffer) WriteU16

func (b *IntBuffer) WriteU16(v uint16)

func (*IntBuffer) WriteU24

func (b *IntBuffer) WriteU24(v uint32)

func (*IntBuffer) WriteU32

func (b *IntBuffer) WriteU32(v uint32)

func (*IntBuffer) WriteU48

func (b *IntBuffer) WriteU48(v uint64)

func (*IntBuffer) WriteU64

func (b *IntBuffer) WriteU64(v uint64)

func (*IntBuffer) WriteU8

func (b *IntBuffer) WriteU8(v byte)

type RuntimeEnv

type RuntimeEnv struct {
	CpuNum     uint32
	MemorySize uint64

	// linux下为uname中Machine字段, 参照 https://en.wikipedia.org/wiki/Unamehttps://stackoverflow.com/questions/45125516/possible-values-for-uname-m
	Arch string // 如 x86_64, aarch64, ppc64, armv7l, amd64, i686, i386, mips, sun4u

	// OS名称+版本号, 参照 github.com/shirou/gopsutil/v3/host/host_linux.go:PlatformInformationWithContext
	OS string // 如 ubuntu 11.04, centos 7.5.1804, fedora 19, redhat xx, linuxmint xx等

	// linux下为uname的Release字段
	KernelVersion string // 如 4.19.17
}

运行环境信息

func GetRuntimeEnv

func GetRuntimeEnv() RuntimeEnv

type StructBuffer

type StructBuffer struct {
	New func() interface{}
	// contains filtered or unexported fields
}

适用于存放可重用的、小规模对象

func (*StructBuffer) Get

func (b *StructBuffer) Get() interface{}

func (*StructBuffer) Reset

func (b *StructBuffer) Reset()

func (*StructBuffer) Slice

func (b *StructBuffer) Slice() []interface{}

Jump to

Keyboard shortcuts

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