Categorygithub.com/more-infra/base
modulepackage
0.0.0-20241027000905-5e451f0e72aa
Repository: https://github.com/more-infra/base.git
Documentation: pkg.go.dev

# README

more-infra/base

Github CI Go Report Card Release Go Reference License: MIT

The basic structures and design modes which could be used by projects.
It includes many typical and common data structures,functions for basic using.

Packages

namedescription
errorbasic struct for error interface which has more information wrapped
runnerbackground goroutine controller with channel sign and sync.WaitGroup
statuswork status controller such as starting,started,stopping,stopped
elementitem container supports safe thread operations and provides simple features database used, such as index,search
queuechan with dynamic capacity
reactorreactor design mode for resolving sync locking and concurrent controlling, which is similar to event loop processing
mcontextput multiple contexts into one which implements the context.Context interface
chanpooldo select for multiple channels which is ambiguous
triggerpack input elements stream to batch by controlling params or function
valuesstrings matcher with multiple regex and wildcard pre-built
varfmtformat string with variable by custom syntax and variable value provider
schedulerdynamic goroutine pool for executing tasks, which could be controlled by custom options
kvconvert between struct object with tag defined and map[string]interface{} like json/yaml Marshal/Unmarshal do.

Development

Now, this project is in developing stage, so the code is changing frequently. A new version will be published every week at Friday.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

ErrorType return Type field of the Error object, it will return "unknown" when the input is not type of *base.Error.
NewConfigError create an error object with "config" Type.
NewError create an error object wrapped input err, default Type is "unknown", you can set the Type by WithType method later.
NewErrorWithType create an error object wrapped input err with the given Type field.
OriginalError return Err field of the Error object, it will return the input object self when it's not type of *base.Error.
WrapError uses to create a new error object or wrapped exist *base.Error.

# Constants

ErrTypeConfig is a common error type using when the error is happened by config paring or checking.
ErrTypeUnknown is the default value for Error's Type field, set a custom Type By NewErrorWithType or NewErrorType,WithType is recommended.

# Structs

Error struct is the basic error wrapper struct, which is widely used in projects.