pkg

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 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")
	ErrSendEOF                   = errors.New("send EOF")
)

Functions

func B2S

func B2S(b []byte) string

func JSONUnmarshal added in v0.1.7

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

func JoinErrors

func JoinErrors(errs []error) error

func Recover

func Recover()

func RecoverWithFunc

func RecoverWithFunc(f func(r any))

Types

type AtomicBool added in v0.1.10

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

func NewAtomicBool added in v0.1.10

func NewAtomicBool() *AtomicBool

func (*AtomicBool) Load added in v0.1.10

func (b *AtomicBool) Load() bool

func (*AtomicBool) Store added in v0.1.10

func (b *AtomicBool) Store(value bool)

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]) 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