Documentation
¶
Index ¶
- Variables
- func AnonymizeIP(ip string) string
- func Chunk[T any](items []T, chunkSize int) (chunks [][]T)
- func Eq(s1, s2 string) bool
- func Hash(str string) string
- func IsNil(i any) bool
- func IsValidIP(ipStr string) bool
- func MapFromSlice[T cmp.Ordered](slice []T) map[T]bool
- func MapKeys[T cmp.Ordered, V any](data map[T]V) []T
- func MergeMapKeys[V any](m map[string]V, adds ...map[string]V) []string
- func MergeSlices[K cmp.Ordered](slices ...[]K) []K
- func RemoveFromSlice[K comparable](base, toRemove []K) []K
- func Reverse[T any](slice []T)
- func SliceToString(slice []string, delimiter string, hook func(string) string) string
- func StringToInt(value string, optionalDefaultValue ...int) int
- func StringToSlice(value string, optionalDefaultValue ...string) []string
- func Truncate(s string, length int) string
- func Uniq(slice []string) []string
- func Unquote(s string) string
- type AggregateError
- type ErrorResponse
- type List
- type MatrixError
- type Mutex
- type StringsBuilder
- func (sb *StringsBuilder) B(b byte) *StringsBuilder
- func (sb *StringsBuilder) Cap() int
- func (sb *StringsBuilder) Grow(n int) *StringsBuilder
- func (sb *StringsBuilder) Len() int
- func (sb *StringsBuilder) R(r rune) *StringsBuilder
- func (sb *StringsBuilder) Reset() *StringsBuilder
- func (sb *StringsBuilder) S(s string) *StringsBuilder
- func (sb *StringsBuilder) String() string
- func (sb *StringsBuilder) Unwrap() strings.Builder
- func (sb *StringsBuilder) Write(p []byte) (int, error)
- func (sb *StringsBuilder) WriteRune(r rune) (int, error)
- func (sb *StringsBuilder) WriteString(s string) (int, error)
- type WaitGroup
Constants ¶
This section is empty.
Variables ¶
var ErrUnknown = errors.New("unknown error")
ErrUnknown represents an unknown error
Functions ¶
func AnonymizeIP ¶ added in v1.7.0
AnonymizeIP drops the last octet of the IPv4 and IPv6 address to anonymize it
func IsNil ¶ added in v1.7.6
IsNil checks if the given value is nil, including interfaces holding nil pointers
func IsValidIP ¶ added in v1.7.4
IsValidIP checks if the given string is a valid IPv4 or IPv6 address by: - ensuring the format is correct - ensuring the IP is not an unspecified, loopback, private, multicast, or link-local address
func MapFromSlice ¶ added in v1.7.2
MapFromSlice creates a map from slice elements as keys The map values are set to true, indicating the presence of the key. This is useful for quickly checking if a key exists in the map.
func MergeMapKeys ¶
MergeMapKeys returns map keys only from multiple maps
func MergeSlices ¶
MergeSlices and remove duplicates
func RemoveFromSlice ¶
func RemoveFromSlice[K comparable](base, toRemove []K) []K
RemoveFromSlice removes elements of toRemove from base slice
func SliceToString ¶
SliceToString converts slice of strings into single string (using strings.Join) with optional hook
func StringToInt ¶
StringToInt converts string to int with optional default value
func StringToSlice ¶
StringToSlice converts comma-separated string to slice with optional default value
Types ¶
type AggregateError ¶ added in v1.7.7
type AggregateError struct {
Errors []error
// contains filtered or unexported fields
}
AggregateError represents an aggregate of multiple errors
func NewAggregateError ¶ added in v1.7.7
func NewAggregateError(errs ...error) *AggregateError
NewAggregateError creates a new aggregate error
func (*AggregateError) As ¶ added in v1.7.7
func (a *AggregateError) As(target any) bool
As checks if the target error type is in the aggregate
func (*AggregateError) Error ¶ added in v1.7.7
func (a *AggregateError) Error() string
Error returns the aggregated error messages
func (*AggregateError) Is ¶ added in v1.7.7
func (a *AggregateError) Is(target error) bool
Is checks if the target error is in the aggregate
func (*AggregateError) Join ¶ added in v1.7.7
func (a *AggregateError) Join(errs ...error) *AggregateError
Join adds errors to the aggregate and returns nil if no errors were added
func (*AggregateError) Unwrap ¶ added in v1.7.7
func (a *AggregateError) Unwrap() []error
Unwrap returns the underlying errors WARNING: This method returns original slice. Do not modify it.
type ErrorResponse ¶
type ErrorResponse struct {
StatusCode int `json:"-"` // HTTP status code, optional, not serialized
Err string `json:"error"` // Error message
// contains filtered or unexported fields
}
ErrorResponse represents an error response
func NewErrorResponse ¶
func NewErrorResponse(err error, optionalStatusCode ...int) *ErrorResponse
NewErrorResponse creates a new error response
func (ErrorResponse) Unwrap ¶ added in v1.7.7
func (e ErrorResponse) Unwrap() error
Unwrap returns the underlying error
type List ¶
List is unique list, V is used only for AddMapKeys
func NewListFrom ¶
NewListFrom creates a new list and popupates it from slice
func (*List[T, V]) AddMapKeys ¶
func (l *List[T, V]) AddMapKeys(datamap map[T]V)
AddMapKeys adds keys from map to the list
func (*List[T, V]) AddSlice ¶
func (l *List[T, V]) AddSlice(dataslice []T)
AddSlice adds keys from slice to the list
func (*List[T, V]) RemoveSlice ¶
func (l *List[T, V]) RemoveSlice(dataslice []T)
RemoveSlice removes items from data using slice
type MatrixError ¶
MatrixError represents an error response from the Matrix API
func MatrixErrorFrom ¶
func MatrixErrorFrom(r io.Reader) *MatrixError
MatrixErrorFrom creates a new Matrix error from io.Reader
func NewMatrixError ¶
func NewMatrixError(code, err string) *MatrixError
NewMatrixError creates a new Matrix error
type Mutex ¶ added in v1.4.0
type Mutex struct {
// contains filtered or unexported fields
}
Mutex is a key-based mutex that allows locking and unlocking based on a key.
type StringsBuilder ¶ added in v1.7.5
type StringsBuilder struct {
// contains filtered or unexported fields
}
StringsBuilder is a wrapper around strings.Builder with short syntax, it also exposes all methods of strings.Builder, so you can use it as a drop-in replacement
func NewStringsBuilder ¶ added in v1.7.5
func NewStringsBuilder() StringsBuilder
NewStringsBuilder creates a new StringsBuilder instance
func (*StringsBuilder) B ¶ added in v1.7.5
func (sb *StringsBuilder) B(b byte) *StringsBuilder
B is shortcut for WriteByte
func (*StringsBuilder) Cap ¶ added in v1.7.5
func (sb *StringsBuilder) Cap() int
Cap returns the current capacity of the accumulated string
func (*StringsBuilder) Grow ¶ added in v1.7.5
func (sb *StringsBuilder) Grow(n int) *StringsBuilder
Grow grows sb's capacity, if necessary, to guarantee space for another n bytes
func (*StringsBuilder) Len ¶ added in v1.7.5
func (sb *StringsBuilder) Len() int
Len returns the current length of the accumulated string
func (*StringsBuilder) R ¶ added in v1.7.5
func (sb *StringsBuilder) R(r rune) *StringsBuilder
R is shortcut for WriteRune
func (*StringsBuilder) Reset ¶ added in v1.7.5
func (sb *StringsBuilder) Reset() *StringsBuilder
Reset resets the StringsBuilder to be empty and returns itself
func (*StringsBuilder) S ¶ added in v1.7.5
func (sb *StringsBuilder) S(s string) *StringsBuilder
S is shortcut for WriteString
func (*StringsBuilder) String ¶ added in v1.7.5
func (sb *StringsBuilder) String() string
String returns the accumulated string
func (*StringsBuilder) Unwrap ¶ added in v1.7.5
func (sb *StringsBuilder) Unwrap() strings.Builder
Unwrap returns the underlying strings.Builder
func (*StringsBuilder) Write ¶ added in v1.7.5
func (sb *StringsBuilder) Write(p []byte) (int, error)
Write appends the contents of p to sb's buffer
func (*StringsBuilder) WriteRune ¶ added in v1.7.5
func (sb *StringsBuilder) WriteRune(r rune) (int, error)
WriteRune appends the UTF-8 encoding of Unicode code point r to sb's buffer
func (*StringsBuilder) WriteString ¶ added in v1.7.5
func (sb *StringsBuilder) WriteString(s string) (int, error)
WriteString appends the contents of s to sb's buffer
type WaitGroup ¶ added in v1.7.3
type WaitGroup struct {
// contains filtered or unexported fields
}
WaitGroup is a wrapper around sync.WaitGroup to have some syntax sugar It does not provide any additional functionality
func NewWaitGroup ¶ added in v1.7.3
func NewWaitGroup() *WaitGroup
NewWaitGroup creates a new WaitGroup
func (*WaitGroup) Do ¶ added in v1.7.3
func (w *WaitGroup) Do(f ...func())
Do runs the given functions in separate goroutines and waits for them to complete
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
format
module
|
|
|
Package retry provides a simple retry mechanism for Go with exponential backoff and jitter.
|
Package retry provides a simple retry mechanism for Go with exponential backoff and jitter. |
|
Package template provides a handy wrapper around text/template package.
|
Package template provides a handy wrapper around text/template package. |
|
package workpool provides a simple work pool implementation
|
package workpool provides a simple work pool implementation |