utils

package
v0.0.0-...-3422fec Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR = "\033[1;31;40m[ERROR] %s\033[0m"
	WARN  = "\033[1;33;40m[WARN] %s\033[0m"
	INFO  = "\033[1;34;40m[INFO] %s\033[0m"
)

Variables

This section is empty.

Functions

func CheckAndCreateFile

func CheckAndCreateFile(filePath string, flag int, perm os.FileMode) (*os.File, error)

func Env

func Env() string

func GetValueOnEnv

func GetValueOnEnv(prod, test interface{}) interface{}

func Int64Ptr

func Int64Ptr(v int64) *int64

func IsTest

func IsTest() bool

func MaxInt64

func MaxInt64(a, b int64) int64

func MinInt64

func MinInt64(a, b int64) int64

func WrapError

func WrapError(format string, args ...any) string

func WrapInfo

func WrapInfo(format string, args ...any) string

func WrapWarn

func WrapWarn(format string, args ...any) string

Types

type Lru

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

func NewLRU

func NewLRU(size int) *Lru

func (*Lru) Read

func (lru *Lru) Read(key interface{}) interface{}

func (*Lru) Remove

func (lru *Lru) Remove(key interface{}) interface{}

func (*Lru) Traverse

func (lru *Lru) Traverse(do func(item interface{}) error, skipErr bool) error

Traverse 遍历lru中的存储元素,对每个元素执行do方法 如果执行do方法过程中出现错误,Traverse 会根据 skipErr 决定是否忽略错误,即当 skipErr 为true时,Traverse 不会返回错误 当 skipErr 为false时,Traverse 会返回第一个出现的错误

func (*Lru) Write

func (lru *Lru) Write(key, data interface{}) interface{}

todo:lock性能

type UnboundChan

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

func NewUnboundChan

func NewUnboundChan() *UnboundChan

func (*UnboundChan) Close

func (uc *UnboundChan) Close()

func (*UnboundChan) In

func (uc *UnboundChan) In()

func (*UnboundChan) Len

func (uc *UnboundChan) Len() int64

func (*UnboundChan) Out

func (uc *UnboundChan) Out() bool

Jump to

Keyboard shortcuts

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