pkg

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LogLevelDebug = LogLevel(0)
	LogLevelInfo  = LogLevel(1)
	LogLevelWarn  = LogLevel(2)
	LogLevelError = LogLevel(3)
)

Variables

View Source
var (
	ErrServerNotSupport          = errors.New("this feature server not support")
	ErrRequestInvalid            = errors.New("request invalid")
	ErrLackResponseChan          = errors.New("lack response chan")
	ErrDuplicateResponseReceived = errors.New("duplicate response received")
	ErrMethodNotSupport          = errors.New("method not support")
	ErrJsonUnmarshal             = errors.New("json unmarshal error")
	ErrSessionHasNotInitialized  = errors.New("the session has not been initialized")
	ErrLackSession               = errors.New("lack session")
)

Functions

func B2S

func B2S(b []byte) string

func JoinErrors

func JoinErrors(errs []error) error

func JsonUnmarshal

func JsonUnmarshal(data []byte, v interface{}) error

func NewBoolAtomic

func NewBoolAtomic() *atomic.Value

func Recover

func Recover()

func RecoverWithFunc

func RecoverWithFunc(f func(r any))

Types

type LogLevel

type LogLevel uint32

type Logger

type Logger interface {
	Debugf(format string, a ...any)
	Infof(format string, a ...any)
	Warnf(format string, a ...any)
	Errorf(format string, a ...any)
}
var DebugLogger Logger = &defaultLogger{
	logLevel: LogLevelDebug,
}
var DefaultLogger Logger = &defaultLogger{
	logLevel: LogLevelInfo,
}

type ResponseError

type ResponseError struct {
	Code    int
	Message string
	Data    interface{}
}

func NewResponseError

func NewResponseError(code int, message string, data interface{}) *ResponseError

func (*ResponseError) Error

func (e *ResponseError) Error() string

type SyncMap

type SyncMap[V any] struct {
	// contains filtered or unexported fields
}

func (*SyncMap[V]) Delete

func (m *SyncMap[V]) Delete(key string)

func (*SyncMap[V]) IsEmpty

func (m *SyncMap[V]) IsEmpty() bool

func (*SyncMap[V]) Load

func (m *SyncMap[V]) Load(key string) (value V, ok bool)

func (*SyncMap[V]) LoadAndDelete

func (m *SyncMap[V]) LoadAndDelete(key string) (value V, loaded bool)

func (*SyncMap[V]) LoadOrStore

func (m *SyncMap[V]) LoadOrStore(key string, value V) (actual V, loaded bool)

func (*SyncMap[V]) Range

func (m *SyncMap[V]) Range(f func(key string, value V) bool)

func (*SyncMap[V]) Store

func (m *SyncMap[V]) Store(key string, value V)

Jump to

Keyboard shortcuts

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