Documentation ¶
Overview ¶
Package utils for golang tools functions
Package utils for calmwu golang tools
Index ¶
- Constants
- Variables
- func Apply(slice, function interface{}) (interface{}, error)
- func ApplyInPlace(slice, function interface{}) error
- func ArrayToString(a []int, delim string) string
- func Bytes2String(b []byte) string
- func BytesPointer(b []byte) unsafe.Pointer
- func CallStack(skip int) string
- func CheckDir(dirPath string) error
- func Choose(slice, function interface{}) (interface{}, error)
- func ChooseInPlace(slice, function interface{}) error
- func CmdExec(args ...string) (outStr string, errStr string, err error)
- func CmdExecCaptureAndShow(args ...string) (outStr string, errStr string, err error)
- func ConvertHashToObj(m interface{}, rawVal interface{}, tagName string) error
- func ConvertMap2PBStruct(v map[string]interface{}) *st.Struct
- func ConvertPBStruct2Map(s *st.Struct) (map[string]interface{}, error)
- func ConvertSysCallNR2Str_X86_64(syscallNR int) (string, error)
- func ConvertToFloat64(i interface{}, defaultValue float64) (ret float64)
- func ConvertToInt(i interface{}, defaultValue int) int
- func ConvertToInt64(i interface{}, defaultValue int64) (ret int64)
- func ConvertToString(i interface{}, defaultValue string) (ret string)
- func Crc16(buf string) uint16
- func CreateZapLog(logFullName string, maxSize, maxAge, maxBackups int, compress bool, ...) *zap.SugaredLogger
- func CurGoroutineID() uint64
- func DPanic(args ...interface{})
- func DPanicf(template string, args ...interface{})
- func Debug(args ...interface{})
- func Debugf(template string, args ...interface{})
- func DecryptCipherText(cipherBlock cipher.Block, cipherText []byte) ([]byte, error)
- func DeleteModuleSymbolTbl(buildID string)
- func Drop(slice, function interface{}) (interface{}, error)
- func DropInPlace(slice, function interface{}) error
- func DumpStacks()
- func EncryptPlainText(cipherBlock cipher.Block, plainText []byte) ([]byte, error)
- func Error(args ...interface{})
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(template string, args ...interface{})
- func FindKsym(addr uint64) (name string, err error)
- func Forever(f func(), period time.Duration)
- func GenerateDHKey() (*dhkx.DHKey, error)
- func GenerateEncryptionKey(pub []byte, privateKey *dhkx.DHKey) ([]byte, error)
- func GeneratePassword(minLength int, maxLength int) string
- func GenerateRandomID() string
- func GenerateRandomPrivateMacAddr() (string, error)
- func GenerateTLSConfig() *tls.Config
- func GetCallStack() string
- func GetClientAddrFromGin(c *gin.Context) string
- func GetDate() string
- func GetDateByLocation(location *time.Location) string
- func GetDateHour() string
- func GetDateNum(location *time.Location) int
- func GetDateNum2(now *time.Time) int
- func GetDayEndTimeLocal() time.Time
- func GetDayEndTimeUtc() time.Time
- func GetHostByteOrder() binary.ByteOrder
- func GetIPByIfname(ifname string) (string, error)
- func GetMonthName(location *time.Location) int
- func GetMonthlyDayCount(year, month int) int
- func GetNextDayStartTimeByLocation(location *time.Location) time.Time
- func GetNextDayStartTimeLocal() time.Time
- func GetNextDayStartTimeUtc() time.Time
- func GetTimeByTz(tz string) (*time.Time, error)
- func GetTimeStampMs() string
- func GetTimeStampSec() string
- func GetTypeName(obj interface{}) (name1, name2, name3 string)
- func GetWeekDay(location *time.Location) int32
- func GetWeekName(location *time.Location) int
- func GinLogger() gin.HandlerFunc
- func GinRecovery() gin.HandlerFunc
- func GorillaConnSocketFD(conn *websocket.Conn) int
- func HashStr2Uint32(s string) uint32
- func HashStr2Uint64(s string) uint64
- func Info(args ...interface{})
- func Infof(template string, args ...interface{})
- func InitDefaultZapLog(logFullName string, logLevel zapcore.LevelEnabler, callSkip int)
- func InitModuleSymbolTblMgr(capacity int) error
- func InstallPProf(address string) error
- func IsInterfaceNil(v interface{}) bool
- func IsLoopback(ip_str string) (bool, error)
- func IsNil(i interface{}) bool
- func IsPrime(n int64) bool
- func Jitter(duration time.Duration, maxFactor float64) time.Duration
- func JitterUntil(f func(), period time.Duration, jitterFactor float64, sliding bool, ...)
- func JitterUntilWithContext(ctx context.Context, f func(context.Context), period time.Duration, ...)
- func Join(a []interface{}, sep string) string
- func JumpHash(key uint64, numBuckets int) int32
- func KsymNameExists(name string) bool
- func LoadKallSyms() error
- func LocalIpAddrs() ([]net.IP, error)
- func LocalIpAddrsAsStrings(include_loopbacks bool) ([]string, error)
- func MachineID() string
- func MapstructUnPackByJSONTag(m, rawVal interface{}) error
- func Max(x int, y int) int
- func MaxListenerBacklog() int
- func MaxSubarraySum(array []int) int
- func MeasureFunc() func()
- func MemUsage() string
- func MergeMap(a, b map[string]interface{}) map[string]interface{}
- func MkDir(dirPath string) error
- func NetConnsocketFD(conn net.Conn) int
- func NewBaseHttpClient(dialTimeout time.Duration, maxIdleConns, maxIdleConnsPerHost int) *http.Client
- func NewCipherBlock(encryptionKey []byte) (cipher.Block, error)
- func NewDefaultErrCheck(printFunc func(format string, data ...interface{}), printStack bool)
- func NewError(args ...interface{}) error
- func NewSimpleLog(out io.Writer) *log.Logger
- func NewTimeoutHTTPClient(connectTimeout time.Duration, readWritetimeout time.Duration) *http.Client
- func NonSlidingUntil(f func(), period time.Duration, stopCh <-chan struct{})
- func NonSlidingUntilWithContext(ctx context.Context, f func(context.Context), period time.Duration)
- func Panic(args ...interface{})
- func Panicf(template string, args ...interface{})
- func ParseUintBytes(s []byte, base int, bitSize int) (n uint64, err error)
- func PathExist(path string) error
- func Poll(interval, timeout time.Duration, condition ConditionFunc) error
- func PollInfinite(interval time.Duration, condition ConditionFunc) error
- func PostRequest(url string, data []byte) ([]byte, int, error)
- func PrimesInRange(min int64, max int64) (primeArr []int64)
- func PrintPerformTimeConsuming(funcName string, startTime time.Time)
- func RandStringBytesMaskImpr(n int) string
- func RandomBytes(size int) ([]byte, error)
- func RandomInt(n int) int
- func RandomRangeIn(low, hi int) int
- func Reduce(slice, pairFunction, zero interface{}) (interface{}, error)
- func RegisterWebItf(webItfPath, httpMethodType string, handlerFunc gin.HandlerFunc, ...)
- func RegisterWebItfsToGin(router *gin.Engine, webItfMap WebItfMap)
- func ReverseString(s string) string
- func ReverseWords(s string) string
- func RunCommand(name string, args ...string) (stdout string, stderr string, exitCode int)
- func SeedMathRand()
- func SendResponse(c *gin.Context, data []byte)
- func SendResponseToClient(c *gin.Context, res *ProtoResponseS)
- func SetKeepAlive(fd, secs int) error
- func SetRecvBuf(c *net.TCPConn, recvBufSize int) error
- func SetReuseAddrAndPort(socketFD int) error
- func SetupSignalHandler() context.Context
- func ShortCallerWithClassFunctionEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)
- func SockaddrToAddr(sa syscall.Sockaddr) net.Addr
- func String2Bytes(s string) []byte
- func StringPointer(s string) unsafe.Pointer
- func TcpConnSocketFD(conn *net.TCPConn) int
- func TcpListenerSocketFD(listener *net.TCPListener) int
- func TimeName(t time.Time) string
- func TimeTaken(t time.Time, name string)
- func ToValue(v interface{}) *st.Value
- func UdpConnSocketFD(conn *net.UDPConn) int
- func Uname() (string, string, error)
- func Until(f func(), period time.Duration, stopCh <-chan struct{})
- func UntilWithContext(ctx context.Context, f func(context.Context), period time.Duration)
- func WaitFor(wait WaitFunc, fn ConditionFunc, done <-chan struct{}) error
- func Warn(args ...interface{})
- func Warnf(template string, args ...interface{})
- func WritePidFile(path string) error
- func ZlibCompress(data []byte, compressLevel int) ([]byte, error)
- func ZlibDCompress(data []byte) ([]byte, error)
- type AtomicBool
- type BCall
- type Backoff
- type BarrierCalls
- type Buffer
- type BuildID
- type BuildIDType
- type ChannelCustomName
- type ChannelCustomNameChannel
- type ChannelCustomType
- type Clock
- type ConditionFunc
- type Epoll
- type EpollConn
- type EpollConnType
- type EpollEvent
- type FactoryReferenceCountable
- type GoModuleSymbolTbl
- type Group
- type Ksym
- type LRUCache
- type LRUCacheFunctions
- type LRUCacheNode
- type ModuleSym
- type ModuleSymbol
- type ModuleSymbolTbl
- type ModuleSymbolTblMgr
- type NativeModuleSymbolTbl
- type NetErrorType
- type NoCopy
- type ProcLangType
- type ProcMaps
- type ProcMapsModule
- type ProcModuleELFType
- type ProcModulePermissions
- type ProcPartition
- type ProtoData
- type ProtoFailInfoS
- type ProtoRequestHeadS
- type ProtoRequestS
- type ProtoResponseHeadS
- type ProtoResponseS
- type ProtoReturnCode
- type RateLimiter
- type ReferenceCountable
- type ReferenceCountedPool
- type ReferenceCounter
- type ResetReferenceCountable
- type ResolveSymbol
- type RingArrayGrowing
- type RingBuffer
- func (r *RingBuffer) Capacity() int
- func (r *RingBuffer) Free() int
- func (r *RingBuffer) IsEmpty() bool
- func (r *RingBuffer) IsFull() bool
- func (r *RingBuffer) Length() int
- func (r *RingBuffer) Read(p []byte) (n int, err error)
- func (r *RingBuffer) ReadByte() (b byte, err error)
- func (r *RingBuffer) Reset()
- func (r *RingBuffer) Write(p []byte) (n int, err error)
- func (r *RingBuffer) WriteByte(b byte) error
- func (r *RingBuffer) WriteString(s string) (n int, err error)
- type Semaphore
- type SortedSliceName
- type SortedSliceNameWrap
- type SortedSliceObjType
- type SymbolTable
- type Timer
- type TypeRegister
- type WaitFunc
- type WebInterfaceInfo
- type WebItfMap
- type WorkerHandler
- type WorkerPool
Constants ¶
const ( EPOLLIN = unix.EPOLLIN EPOLLOUT = unix.EPOLLOUT EPOLLRDHUP = unix.EPOLLRDHUP EPOLLPRI = unix.EPOLLPRI EPOLLERR = unix.EPOLLERR EPOLLHUP = unix.EPOLLHUP EPOLLET = unix.EPOLLET EPOLLONESHOT = unix.EPOLLONESHOT )
EpollEvents that are mapped to epoll_event.events possible values.
const DefaultConcurrency = 256 * 1024
DefaultConcurrency 默认的并发数量
const (
HashSeed = 0x2a
)
const (
KeyBytesSize = 32
)
https://www.cnblogs.com/si812cn/archive/2009/11/26/1611272.html g是p的原根Diffie-Hellman密钥交换算法的有效性依赖于计算离散对数的难度。简言之,可以如下定义离散对数:首先定义一个素数p的原根,为其各次幂产生从1 到p-1的所有整数根,也就是说,如果a是素数p的一个原根,那么数值 a mod p, a2 mod p, ..., ap-1 mod p 是各不相同的整数,并且以某种排列方式组成了从1到p-1的所有整数。
Variables ¶
var ( // ErrClosed is returned by Poller methods to indicate that instance is // closed and operation could not be processed. ErrClosed = fmt.Errorf("poller instance is closed") // ErrRegistered is returned by Poller Start() method to indicate that // connection with the same underlying file descriptor was already // registered within the poller instance. ErrRegistered = fmt.Errorf("file descriptor is already registered in poller instance") // ErrNotRegistered is returned by Poller Stop() and Resume() methods to // indicate that connection with the same underlying file descriptor was // not registered before within the poller instance. ErrNotRegistered = fmt.Errorf("file descriptor was not registered before in poller instance") )
var ( ErrNoSliceType = errors.New("not slice type") ErrNoFuncType = errors.New("no func type") ErrFuncSignatureInvalid = errors.New("func signature invalid") ErrFuncInTypeNoMatch = errors.New("func in parameter type not match with slice elem") ErrFuncOutTypeNoMatch = errors.New("func out parameter type not match") ErrSliceNotPtr = errors.New("slice not ptr") )
var ( ErrGSTTextSectionEmpty = errors.New(".text section is empty") ErrGSTGoPCLNTabNotExist = errors.New("no .gopclntab section") ErrGSTGoPCLNTabEmpty = errors.New(".gopclntab section is empty") ErrGSTGoSymTabNotExist = errors.New("no .gosymtab section") ErrGSTGoTooOld = errors.New("gosymtab: go sym tab too old") ErrGSTGoParseFailed = errors.New("gosymtab: go sym tab parse failed") ErrGSTGoFailed = errors.New("gosymtab: go sym tab failed") ErrGSTGoOOB = errors.New("go table oob") ErrGSTGoSymbolsNotFound = errors.New("gosymtab: no go symbols found") )
var ( ErrProcModuleNotSupport = errors.New("proc module not support") ErrProcModuleNotSymbolSection = errors.New("proc module not symbol section") ErrProcModuleHasNoSymbols = errors.New("proc module has no symbols") )
var ( ErrRingBufEmpty = errors.New("ringbuffer is empty") ErrRingBufFull = errors.New("ringbuffer is full") ErrRingSpaceNotEnough = errors.New("ringbuffer space is not enough") )
var ( // DefaultErrCheck error判断和列出上下文 DefaultErrCheck = errlog.NewLogger(&errlog.Config{ PrintFunc: Debugf, PrintSource: true, LinesBefore: 2, LinesAfter: 1, PrintError: true, PrintStack: false, ExitOnDebugSuccess: false, }) )
var (
ErrNoBuildIDSection = errors.New("build ID section not found")
)
var ErrNoOne = errors.New("lis.TypeRegister.Get: no one")
var ErrSemTimeout = errors.New("semaphore: acquire timeout")
var ErrTooLarge = errors.New("bytes.Buffer: too large")
var ErrWaitTimeout = errors.New("timed out waiting for the condition")
var ForeverTestTimeout = time.Second * 30
var NerverStop <-chan struct{} = make(chan struct{})
var ( // SeededSecurely 变量 SeededSecurely bool )
var TypeReg = make(TypeRegister)
TypeReg shared type register
var (
ZLog *zap.SugaredLogger
)
Functions ¶
func Apply ¶
func Apply(slice, function interface{}) (interface{}, error)
Apply takes a slice of type []T and a function of type func(T) T.
func ApplyInPlace ¶
func ApplyInPlace(slice, function interface{}) error
ApplyInPlace is like Apply, not allocated slice
func ArrayToString ¶
func Bytes2String ¶
Bytes2String 不要在使用 []byte(string) 或 string([]byte) 这类类型转换 http://www.flysnow.org/2017/07/06/go-in-action-unsafe-pointer.html https://studygolang.com/articles/2909 unsafe.Pointer 类似 void*
func BytesPointer ¶
BytesPointer convert byte slice to pointer
func Choose ¶
func Choose(slice, function interface{}) (interface{}, error)
Choose 选择function返回true的元素, 返回一个新分配的slice
func ChooseInPlace ¶
func ChooseInPlace(slice, function interface{}) error
ChooseInPlace 选择function返回true的元素
func CmdExecCaptureAndShow ¶
CmdExecCaptureAndShow 捕获输出
func ConvertHashToObj ¶
func ConvertMap2PBStruct ¶
ConvertMapToPBStruct converts a map[string]interface{} to a ptypes.Struct
func ConvertPBStruct2Map ¶
ConvertPBStruct2Map converts a ptypes.Struct to a map[string]interface{}
func ConvertSysCallNR2Str_X86_64 ¶
Convert an x86_64 syscall number to a string
func ConvertToFloat64 ¶
func ConvertToInt ¶
func ConvertToInt64 ¶
func ConvertToString ¶
func CreateZapLog ¶
func CreateZapLog(logFullName string, maxSize, maxAge, maxBackups int, compress bool, logLevel zapcore.LevelEnabler, callSkip int) *zap.SugaredLogger
CreateZapLog 创建log对象 logFullName: dir/dir/dir/test.log maxSize: megabytes, default = 100 maxAge: 多少天之后变为old file maxBackups: old file备份数量 compress: old file是否压缩tgz logLevel: zapcore.DebugLevel
func DecryptCipherText ¶
DecryptCipherText in-place模式
func DeleteModuleSymbolTbl ¶
func DeleteModuleSymbolTbl(buildID string)
DeleteModuleSymbolTbl deletes the module symbol table for the given build ID.
func Drop ¶
func Drop(slice, function interface{}) (interface{}, error)
Drop 选择function返回false的元素, 返回一个新分配的slice
func DropInPlace ¶
func DropInPlace(slice, function interface{}) error
DropInPlace 选择function返回false的元素
func EncryptPlainText ¶
EncryptPlainText 传入明文,返回密文
func GenerateEncryptionKey ¶
GenerateEncryptionKey 根据对方返回的kb计算加密密钥
func GeneratePassword ¶
func GenerateRandomPrivateMacAddr ¶
GenerateRandomPrivateMacAddr 生成mac地址
func GenerateTLSConfig ¶
GenerateTLSConfig 生成tls配置 https://blog.csdn.net/wangshubo1989/article/details/77508738 https://colobu.com/2016/06/07/simple-golang-tls-examples/ InsecureSkipVerify: true,
func GetCallStack ¶
func GetCallStack() string
func GetClientAddrFromGin ¶
GetClientAddrFromGin 得到客户端地址
func GetDateByLocation ¶
func GetDateHour ¶
func GetDateHour() string
func GetDateNum ¶
func GetDateNum2 ¶
func GetDayEndTimeLocal ¶
func GetDayEndTimeUtc ¶
func GetHostByteOrder ¶
getHostByteOrder returns the host's native binary.ByteOrder.
func GetMonthName ¶
func GetNextDayStartTimeUtc ¶
func GetTimeStampMs ¶
func GetTimeStampMs() string
func GetTimeStampSec ¶
func GetTimeStampSec() string
func GetTypeName ¶
func GetTypeName(obj interface{}) (name1, name2, name3 string)
func GetWeekDay ¶
func GetWeekName ¶
func GorillaConnSocketFD ¶
func HashStr2Uint32 ¶
func HashStr2Uint64 ¶
func InitDefaultZapLog ¶
func InitDefaultZapLog(logFullName string, logLevel zapcore.LevelEnabler, callSkip int)
InitDefaultZapLog 初始化Zap log
func InitModuleSymbolTblMgr ¶
InitModuleSymbolTblMgr initializes the module symbol table manager with the given capacity. It creates a new LRU cache with the specified capacity and sets up the module symbol table manager to use it. If the initialization has already been performed, this function does nothing. Returns an error if there was a problem creating the LRU cache.
func IsLoopback ¶
IsLoopback check if a particular IP notation corresponds to a loopback interface.
func Jitter ¶
Jitter returns a time.Duration between duration and duration + maxFactor * duration.
This allows clients to avoid converging on periodic behavior. If maxFactor is 0.0, a suggested default value will be chosen.
func JitterUntil ¶
func JitterUntil(f func(), period time.Duration, jitterFactor float64, sliding bool, stopCh <-chan struct{})
If sliding is true, the period is computed after f runs. If it is false then period includes the runtime for f.
func JitterUntilWithContext ¶
func JitterUntilWithContext(ctx context.Context, f func(context.Context), period time.Duration, jitterFactor float64, sliding bool)
在执行后开始计算超时
func JumpHash ¶
JumpHash Hash consistently chooses a hash bucket number in the range [0, numBuckets) for the given key. numBuckets must >= 1.
func LoadKallSyms ¶
func LoadKallSyms() error
It reads the /proc/kallsyms file and stores the symbol name and address in a map
func LocalIpAddrs ¶
LocalIpAddrs finds the IP addresses of the hosts on which the shipper currently runs on.
func LocalIpAddrsAsStrings ¶
LocalIpAddrs finds the IP addresses of the hosts on which the shipper currently runs on and returns them as an array of strings.
func MachineID ¶
func MachineID() string
Summary: MachineID is a function that retrieves the machine ID by reading from a list of specified files. It iterates through the list of files and reads the content from the '/proc/1/root' directory. If a valid machine ID is found, it is processed to remove whitespace and dashes before being returned. Parameters:
None
Returns:
string: The machine ID extracted from the files, or an empty string if no valid ID is found.
func MapstructUnPackByJSONTag ¶
func MapstructUnPackByJSONTag(m, rawVal interface{}) error
MapstructUnPackByJSONTag 使用mapstruct进行解包
func NewBaseHttpClient ¶
func NewBaseHttpClient(dialTimeout time.Duration, maxIdleConns, maxIdleConnsPerHost int) *http.Client
NewBaseHttpClient Clients are safe for concurrent use by multiple goroutines. https://colobu.com/2016/07/01/the-complete-guide-to-golang-net-http-timeouts/ https://stackoverflow.com/questions/36773837/best-way-to-use-http-client-in-a-concurrent-application
func NewDefaultErrCheck ¶
func NewTimeoutHTTPClient ¶
func NewTimeoutHTTPClient(connectTimeout time.Duration, readWritetimeout time.Duration) *http.Client
NewTimeoutHTTPClient 构造一个dialTimeout对象
func NonSlidingUntil ¶
在执行前开始计算超时
func NonSlidingUntilWithContext ¶
在执行前开始计算超时,超时时间包括了函数执行时间
func ParseUintBytes ¶
ParseUintBytes is like strconv.ParseUint, but using a []byte.
func PollInfinite ¶
func PollInfinite(interval time.Duration, condition ConditionFunc) error
func PostRequest ¶
PostRequest post请求返回回应,返回body数据,httpcode,错误
func PrimesInRange ¶
func PrintPerformTimeConsuming ¶
PrintPerformTimeConsuming 打印消费时间
func RandStringBytesMaskImpr ¶
RandStringBytesMaskImpr 根据掩码生成随机字符串
func RandomRangeIn ¶
RandomRangeIn trying to generate 8 digit numbers, the range would be (10000000, 99999999)
func Reduce ¶
func Reduce(slice, pairFunction, zero interface{}) (interface{}, error)
Reduce ... func multiply(a, b int) int { return a*b } a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} factorial := Reduce(a, multiply, 1).(int)
func RegisterWebItf ¶
func RegisterWebItf(webItfPath, httpMethodType string, handlerFunc gin.HandlerFunc, webItfMap WebItfMap)
RegisterWebItf 接口注册
func RegisterWebItfsToGin ¶
RegisterWebItfsToGin 注册到gin
func ReverseWords ¶
func RunCommand ¶
RunCommand 运行命令
func SendResponseToClient ¶
func SendResponseToClient(c *gin.Context, res *ProtoResponseS)
func SetKeepAlive ¶
SetKeepAlive 设置 KeepAlive tcp_keepalive_time:间隔多久没有发送数据后,就发送一个心跳包 tcp_keepalive_intvl:发送的心跳包如果没有收到 ack,间隔多久后,重新发送 tcp_keepalive_probes:最多发送多少个心跳包没有收到回复后,认为对方挂掉了 https://mcll.top/2019/07/20/tcp-keepalive-in-go/
func SetReuseAddrAndPort ¶
SetReuseAddrAndPort 设置 SO_REUSEADDR 和 reusePort
func SetupSignalHandler ¶
SetupSignalHandler registers for SIGTERM and SIGINT. A stop channel is returned which is closed on one of these signals. If a second signal is caught, the program is terminated with exit code 1.
func ShortCallerWithClassFunctionEncoder ¶
func ShortCallerWithClassFunctionEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)
func String2Bytes ¶
func TcpConnSocketFD ¶
func TcpListenerSocketFD ¶
func TcpListenerSocketFD(listener *net.TCPListener) int
func UdpConnSocketFD ¶
func Uname ¶
Summary: Uname is a function that retrieves the hostname and kernel version of the current system by switching to the system's UTS namespace and reading the Utsname struct. Parameters:
None
Returns:
string: The hostname of the current system. string: The kernel version of the current system. error: An error, if any, encountered during the retrieval process.
func UntilWithContext ¶
在执行后开始计算超时,超时时间不包括函数执行时间
func WaitFor ¶
func WaitFor(wait WaitFunc, fn ConditionFunc, done <-chan struct{}) error
func WritePidFile ¶
WritePidFile write current process id to file
func ZlibDCompress ¶
Types ¶
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
An AtomicBool is an atomic bool
type BarrierCalls ¶
type BarrierCalls interface {
Do(key string, args interface{}, fn func(args interface{}) (interface{}, error)) (interface{}, bool, error)
}
BarrierCalls 并行访问的接口
func NewBarrierCalls ¶
func NewBarrierCalls() BarrierCalls
type Buffer ¶
type Buffer[T constraints.Unsigned] struct { // contains filtered or unexported fields }
func NewBufferFrom ¶
func NewBufferFrom[T constraints.Unsigned](buf []T) *Buffer[T]
type BuildID ¶
type BuildID struct { Type BuildIDType ID string }
type BuildIDType ¶
type BuildIDType int
const ( BuildIDTypeUnknown BuildIDType = iota BuildIDTypeGNU BuildIDTypeGO )
type ChannelCustomNameChannel ¶
type ChannelCustomNameChannel struct { C chan ChannelCustomType // contains filtered or unexported fields }
ChannelCustomNameChannel channel的封装对象
func NewChannelCustomNameChannel ¶
func NewChannelCustomNameChannel(size int) *ChannelCustomNameChannel
NewChannelCustomNameChannel 创建函数
func (*ChannelCustomNameChannel) IsClosed ¶
func (cc *ChannelCustomNameChannel) IsClosed() bool
IsClosed 判断是否被关闭
func (*ChannelCustomNameChannel) Read ¶
func (cc *ChannelCustomNameChannel) Read(block bool) (val ChannelCustomType, ok bool)
Read 读取
func (*ChannelCustomNameChannel) SafeClose ¶
func (cc *ChannelCustomNameChannel) SafeClose()
SafeClose 安全的关闭channel
func (*ChannelCustomNameChannel) SafeSend ¶
func (cc *ChannelCustomNameChannel) SafeSend(value ChannelCustomType, block bool) (ok, closed bool, err error)
SafeSend 安全的发送数据
type Epoll ¶
type Epoll struct {
// contains filtered or unexported fields
}
type EpollConn ¶
type EpollConn struct { ConnHolder interface{} // golang各种连接对象 ConnArg interface{} // 附加参数 ConnType EpollConnType // 连接类型 TriggerEvents EpollEvent // EpollEvent返回的事件类型 SocketFD int }
type EpollConnType ¶
type EpollConnType int
const ( EPOLLConnTypeTCPCONN EpollConnType = iota EPOLLConnTypeTCPLISTENER EPOLLConnTypeUDP EPOLLConnTypeWEBSOCKET )
type FactoryReferenceCountable ¶
type FactoryReferenceCountable func(ReferenceCounter) ReferenceCountable
type GoModuleSymbolTbl ¶
type GoModuleSymbolTbl struct { ModuleSymbolTbl // contains filtered or unexported fields }
func (*GoModuleSymbolTbl) Count ¶
func (gomst *GoModuleSymbolTbl) Count() int
func (*GoModuleSymbolTbl) GenerateTbl ¶
func (*GoModuleSymbolTbl) Resolve ¶
func (gomst *GoModuleSymbolTbl) Resolve(addr uint64) (*ResolveSymbol, error)
func (*GoModuleSymbolTbl) Symbols ¶
func (gomst *GoModuleSymbolTbl) Symbols() []*ModuleSymbol
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) StartWithChannel ¶
func (g *Group) StartWithChannel(stopCh <-chan struct{}, f func(stopCh <-chan struct{}))
func (*Group) StartWithContext ¶
type LRUCache ¶
type LRUCache struct { Capacity int // 存储要用二维关系,map + 链表 CacheStorage map[string]*LRUCacheNode // 匿名接口 LRUCacheFunctions // contains filtered or unexported fields }
type LRUCacheFunctions ¶
type LRUCacheNode ¶
type LRUCacheNode struct { Key string Value interface{} // contains filtered or unexported fields }
LRUCacheNode 节点
type ModuleSymbol ¶
type ModuleSymbolTbl ¶
type ModuleSymbolTbl struct {
// contains filtered or unexported fields
}
func (*ModuleSymbolTbl) BuildID ¶
func (mst *ModuleSymbolTbl) BuildID() string
func (*ModuleSymbolTbl) ModuleName ¶
func (mst *ModuleSymbolTbl) ModuleName() string
type ModuleSymbolTblMgr ¶
type ModuleSymbolTblMgr struct {
// contains filtered or unexported fields
}
type NativeModuleSymbolTbl ¶
type NativeModuleSymbolTbl struct { ModuleSymbolTbl // contains filtered or unexported fields }
func (*NativeModuleSymbolTbl) Count ¶
func (nmst *NativeModuleSymbolTbl) Count() int
func (*NativeModuleSymbolTbl) GenerateTbl ¶
func (nmst *NativeModuleSymbolTbl) GenerateTbl(elfF *elf.File) error
func (*NativeModuleSymbolTbl) Resolve ¶
func (nmst *NativeModuleSymbolTbl) Resolve(addr uint64) (*ResolveSymbol, error)
func (*NativeModuleSymbolTbl) Symbols ¶
func (nmst *NativeModuleSymbolTbl) Symbols() []*ModuleSymbol
type NetErrorType ¶
type NetErrorType int
NetErrorType 网络错类型
const ( NETERR_TYPE_NO NetErrorType = iota // NETERR_TYPE_DNSERROR // *net.DNSError NETERR_TYPE_INVALIDADDERROR // *net.InvalidAddrError NETERR_TYPE_UNKNOWNNETWORKERROR // *net.UnknownNetworkError NETERR_TYPE_ADDERROR // *net.AddrError NETERR_TYPE_DNSCONFIGERROR // *net.DNSConfigError NETERR_TYPE_OS_SYSCALLERROR // *os.SyscallError--->syscall.Errno syscall.ECONNREFUSED syscall.ETIMEDOUT )
func NetErrorCheck ¶
func NetErrorCheck(err error) (isNetError bool, netErrEnum NetErrorType, netErr interface{})
func (NetErrorType) String ¶
func (i NetErrorType) String() string
type NoCopy ¶
type NoCopy struct{}
Embed this type into a struct, which mustn't be copied, so `go vet` gives a warning if this struct is copied.
See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details. and also: https://stackoverflow.com/questions/52494458/nocopy-minimal-example
type ProcLangType ¶
type ProcLangType int
module 的语言类型
const ( NativeLangType ProcLangType = iota // c & c++ GoLangType JavaLangType PythonLangType )
type ProcMaps ¶
type ProcMaps struct { // pid Pid int // ProcMapsModule slice ModuleList []*ProcMapsModule // inode, Determine whether to refresh InodeID uint64 // LangType ProcLangType }
func NewProcMaps ¶
func (*ProcMaps) Modules ¶
func (pss *ProcMaps) Modules() []*ProcMapsModule
GetModules 返回进程符号表中的所有模块。
type ProcMapsModule ¶
type ProcMapsModule struct { // StartAddr is the starting pc of current mapping. StartAddr uint64 // EndAddr is the ending pc of current mapping. EndAddr uint64 // Perm is the permission of current mapping. Perms ProcModulePermissions // Offset is the offset of current mapping. Offset uint64 // Dev is the device of current mapping. Dev uint64 // Inode is the inode of current mapping. find / -inum 101417806 or lsof -n -i 'inode=174919' Inode uint64 Pathname string // 内存段所属的文件的路径名 RootFS string // Type ProcModuleELFType // BuildID string // }
func (*ProcMapsModule) String ¶
func (pmm *ProcMapsModule) String() string
A method of the ProcMapsModule struct. It is used to print the ProcMapsModule struct.
type ProcModuleELFType ¶
type ProcModuleELFType int
module 的 elf 类型
const ( UNKNOWN ProcModuleELFType = iota EXEC SO VDSO )
type ProcModulePermissions ¶
type ProcModulePermissions struct { // Readable is true if the mapping is readable. Readable bool // Writable is true if the mapping is writable. Writable bool // Executable is true if the mapping is executable. Executable bool Shared bool // Private is true if the mapping is private. Private bool }
type ProcPartition ¶
func ProcPartitions ¶
func ProcPartitions() ([]ProcPartition, error)
ProcPartitions reads the /proc/partitions file and returns a slice of ProcPartition structs representing the partitions listed in the file.
type ProtoData ¶
type ProtoData struct { InterfaceName string `json:"InterfaceName"` Params interface{} `json:"Params"` }
type ProtoFailInfoS ¶
type ProtoFailInfoS struct {
FailureReason string `json:"FailureReason"`
}
type ProtoRequestHeadS ¶
type ProtoRequestS ¶
type ProtoRequestS struct { ProtoRequestHeadS ReqData ProtoData `json:"ReqData"` }
func UnpackClientRequest ¶
func UnpackClientRequest(c *gin.Context) (*ProtoRequestS, error)
func UnpackRequest ¶
func UnpackRequest(c *gin.Context) *ProtoRequestS
type ProtoResponseHeadS ¶
type ProtoResponseHeadS struct { Version int `json:"Version"` TimeStamp int64 `json:"TimeStamp"` EventID int `json:"EventID"` ReturnCode ProtoReturnCode `json:"ReturnCode"` }
type ProtoResponseS ¶
type ProtoResponseS struct { ProtoResponseHeadS ResData ProtoData `json:"ResData"` }
type ProtoReturnCode ¶
type ProtoReturnCode int
type RateLimiter ¶
type RateLimiter interface { // TryAccept return true if a token is taken immediately, it return false TryAccept() bool // Accept return once a token becomes available Accept() // QPS return QPS of this rate limiter QPS() float32 }
func NewTokenBucketRateLimiter ¶
func NewTokenBucketRateLimiter(qps float32, burst int) RateLimiter
NewTokenBucketRateLimiter burst 桶的深度 qps 每秒的请求数量,也就是每秒的令牌生成数量
func NewTokenBucketRateLimiterWithClock ¶
func NewTokenBucketRateLimiterWithClock(qps float32, burst int, c Clock) RateLimiter
type ReferenceCountable ¶
type ReferenceCountable interface { SetInstance(i interface{}) IncrementReferenceCount() DecrementReferenceCount() }
type ReferenceCountedPool ¶
type ReferenceCountedPool struct {
// contains filtered or unexported fields
}
ReferenceCountedPool 计数对象池
func NewReferenceCountedPool ¶
func NewReferenceCountedPool(factory FactoryReferenceCountable, reset ResetReferenceCountable) *ReferenceCountedPool
NewReferenceCountedPool 生成一个计数对象池
func (*ReferenceCountedPool) Get ¶
func (rcp *ReferenceCountedPool) Get() ReferenceCountable
Get 获取对象
func (*ReferenceCountedPool) Stats ¶
func (rcp *ReferenceCountedPool) Stats() map[string]interface{}
Stats 输出pool的统计
type ReferenceCounter ¶
type ReferenceCounter struct { Count *uint32 `sql:"-" json:"-" yaml:"-"` // 引用计数器 Destinantion *sync.Pool `sql:"-" json:"-" yaml:"-"` // 对象池,用来回收用 Released *uint32 `sql:"-" json:"-" yaml:"-"` // 统计累计释放对象次数 Instance interface{} `sql:"-" json:"-" yaml:"-"` Reset func(interface{}) error `sql:"-" json:"-" yaml:"-"` // 用来清理Instance所有成员 ID uint32 `sql:"-" json:"-" yaml:"-"` }
ReferenceCounter 计数对象类型
func (ReferenceCounter) DecrementReferenceCount ¶
func (rc ReferenceCounter) DecrementReferenceCount()
func (ReferenceCounter) IncrementReferenceCount ¶
func (rc ReferenceCounter) IncrementReferenceCount()
func (*ReferenceCounter) SetInstance ¶
func (rc *ReferenceCounter) SetInstance(i interface{})
type ResetReferenceCountable ¶
type ResetReferenceCountable func(interface{}) error
type ResolveSymbol ¶
type RingArrayGrowing ¶
type RingArrayGrowing struct {
// contains filtered or unexported fields
}
RingArrayGrowing is a growing ring array Not thread safe
func NewRingArrayGrowing ¶
func NewRingArrayGrowing(initialSize int) *RingArrayGrowing
NewRingArrayGrowing construct a new RingArrayGrowing instance
func (*RingArrayGrowing) ReadOne ¶
func (r *RingArrayGrowing) ReadOne() (interface{}, bool)
ReadOne consumes first item from the array if it is avaliable, otherwise return false
func (*RingArrayGrowing) WriteOne ¶
func (r *RingArrayGrowing) WriteOne(item interface{})
WriteOne add an item to the end of the array, growing it if it is full
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer is a circular buffer
func NewRingBuffer ¶
func NewRingBuffer(initialSize int) *RingBuffer
NewRingBuffer construct a new RingBuffer instance
func (*RingBuffer) Free ¶
func (r *RingBuffer) Free() int
Free return length of available bytes to write
func (*RingBuffer) IsEmpty ¶
func (r *RingBuffer) IsEmpty() bool
IsEmpty return this ringbuffer is empty
func (*RingBuffer) IsFull ¶
func (r *RingBuffer) IsFull() bool
IsFull return this ringbuffer is full
func (*RingBuffer) Length ¶
func (r *RingBuffer) Length() int
Length return the length of available read bytes
func (*RingBuffer) Read ¶
func (r *RingBuffer) Read(p []byte) (n int, err error)
Read reads up to len(p) bytes to p
func (*RingBuffer) ReadByte ¶
func (r *RingBuffer) ReadByte() (b byte, err error)
ReadByte read a next byte from the buf or return ErrRingBufEmpty
func (*RingBuffer) Write ¶
func (r *RingBuffer) Write(p []byte) (n int, err error)
Write write len p bytes to underlying buf
func (*RingBuffer) WriteByte ¶
func (r *RingBuffer) WriteByte(b byte) error
func (*RingBuffer) WriteString ¶
func (r *RingBuffer) WriteString(s string) (n int, err error)
WriteString writes the contents of the string s to buffer, which accepts a slice of bytes.
type Semaphore ¶
type Semaphore chan struct{}
func NewSemaphore ¶
type SortedSliceNameWrap ¶
type SortedSliceNameWrap struct { Ssot []*SortedSliceObjType CompareFunc func(left, right *SortedSliceObjType) bool }
SortedSliceWrap
type SymbolTable ¶
type SymbolTable interface { Resolve(addr uint64) (*ResolveSymbol, error) // 解析地址 ModuleName() string // BuildID() string // Count() int // Symbols() []*ModuleSymbol // }
type TypeRegister ¶
TypeRegister - type register
func (TypeRegister) Get ¶
func (t TypeRegister) Get(name string) (interface{}, error)
Get element of type, if no one - err will be ErrNoOne
type WebInterfaceInfo ¶
type WebInterfaceInfo struct { HTTPMethodType string HandlerFunc gin.HandlerFunc }
WebInterfaceInfo web接口方法的描述
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool 协程池对象
func StartWorkerPool ¶
func StartWorkerPool(workerFunc WorkerHandler, maxWorkersCount int, maxIdelWorkerDuration time.Duration) (*WorkerPool, error)
StartWorkerPool 启动协程池
Source Files ¶
- anybuffer.go
- atomic_bool.go
- barrier_calls.go
- buildid.go
- byte_order.go
- callstack.go
- cipher.go
- cmdExec.go
- compress.go
- convert.go
- crc16.go
- epoll.go
- error.go
- file.go
- generic_channel.go
- generic_slicetsort.go
- hash.go
- itf.go
- ksym.go
- lru_cache.go
- machine_info.go
- map.go
- mapreduce.go
- maxsubarraysum.go
- measure.go
- module_symbols.go
- net.go
- neterrortype_string.go
- nocopy.go
- password_generator.go
- pidfile.go
- pprof.go
- prime_numbers.go
- proc_maps.go
- proc_partitions.go
- processinfo.go
- proto.go
- random.go
- referencecount.go
- reflect.go
- request.go
- ringarray_growing.go
- ringbuffer.go
- semaphore.go
- signal.go
- string.go
- throttle.go
- time.go
- timer.go
- wait.go
- web.go
- workerpool.go
- zaplog.go
Directories ¶
Path | Synopsis |
---|---|
Package consulapi for process cousul
|
Package consulapi for process cousul |
Package lifobuffer implements bytes buffer with LIFO order (last-in-first-out)
|
Package lifobuffer implements bytes buffer with LIFO order (last-in-first-out) |
Package redistool for process with redis
|
Package redistool for process with redis |
Package task 任务对象
|
Package task 任务对象 |
Package wordfilter 单词过滤
|
Package wordfilter 单词过滤 |