Documentation ¶
Index ¶
- func Contains[T any](origin []T, element T) bool
- func DurationSecondToInt(d *time.Duration) *int
- func Filter[T any](elements []T, predicate func(T) bool) []T
- func GetWriter(consumer func(string)) io.WriteCloser
- func Remove[T any](origin []T, elements ...T) []T
- func StringContains(array []string, needle string) bool
- func StringToBool(s string) bool
- type SafeBuffer
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶ added in v2.11.0
Contains helps to detect if a non-comparable struct is part of an array only use this method if you can't rely on existing golang Contains function of slices (https://pkg.go.dev/golang.org/x/exp/slices#Contains)
func DurationSecondToInt ¶ added in v2.12.0
func GetWriter ¶
func GetWriter(consumer func(string)) io.WriteCloser
GetWriter creates a io.Writer that will actually split by line and format by LogConsumer
func Remove ¶ added in v2.16.0
func Remove[T any](origin []T, elements ...T) []T
Remove removes all elements from origin slice
func StringContains ¶
StringContains check if an array contains a specific value
func StringToBool ¶ added in v2.3.0
StringToBool converts a string to a boolean ignoring errors
Types ¶
type SafeBuffer ¶ added in v2.12.0
type SafeBuffer struct {
// contains filtered or unexported fields
}
SafeBuffer is a thread safe version of bytes.Buffer
func (*SafeBuffer) Bytes ¶ added in v2.12.0
func (b *SafeBuffer) Bytes() []byte
Bytes is a thread safe version of bytes.Buffer::Bytes
func (*SafeBuffer) Read ¶ added in v2.12.0
func (b *SafeBuffer) Read(p []byte) (n int, err error)
Read is a thread safe version of bytes.Buffer::Read
func (*SafeBuffer) RequireEventuallyContains ¶ added in v2.12.0
func (b *SafeBuffer) RequireEventuallyContains(t testing.TB, v string)
RequireEventuallyContains is a thread safe eventual checker for the buffer content
func (*SafeBuffer) String ¶ added in v2.12.0
func (b *SafeBuffer) String() string
String is a thread safe version of bytes.Buffer::String
type Set ¶ added in v2.16.0
type Set[T comparable] map[T]struct{}
func NewSet ¶ added in v2.21.0
func NewSet[T comparable](v ...T) Set[T]