Documentation
¶
Index ¶
- func IsDir(name string) bool
- func IsFile(name string) bool
- func MapSlice[S any, T any](src []S, mapper func(S) T) []T
- func MustReadOption[T string | int | *zap.SugaredLogger](options map[string]interface{}, key string) T
- func MustReadStringOption(options map[string]interface{}, key string) string
- type ErrorCollection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustReadOption ¶
func MustReadOption[T string | int | *zap.SugaredLogger](options map[string]interface{}, key string) T
MustReadOption read a value from options map. Panic if key does not exist or the type of value is not T.
func MustReadStringOption ¶
MustReadStringOption read a string value from options map. Panic if key does not exist or the value is not a string type.
Types ¶
type ErrorCollection ¶
type ErrorCollection struct {
// contains filtered or unexported fields
}
ErrorCollection is an error that packed a series of errors. Unlike fmt.Errorf, all the errors here are at the same level. The length of errors must > 0.
A typical use case is a function that performs operations on a lot of data, which are independent of each other and do not want to be interrupted by just an error.
func NewErrorCollection ¶
func NewErrorCollection(errs []error) *ErrorCollection
NewErrorCollection create an ErrorCollection based on given errors. If the given errors is nil or empty, then return nil.
func (*ErrorCollection) Error ¶
func (e *ErrorCollection) Error() string