package utils
import "github.com/docker/compose/v2/pkg/utils"
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
- func (b *SafeBuffer) Bytes() []byte
- func (b *SafeBuffer) Read(p []byte) (n int, err error)
- func (b *SafeBuffer) RequireEventuallyContains(t testing.TB, v string)
- func (b *SafeBuffer) String() string
- func (b *SafeBuffer) Write(p []byte) (n int, err error)
- type Set
- func NewSet[T comparable](v ...T) Set[T]
- func (s Set[T]) Add(v T)
- func (s Set[T]) AddAll(v ...T)
- func (s Set[T]) Clear()
- func (s Set[T]) Diff(other Set[T]) Set[T]
- func (s Set[T]) Elements() []T
- func (s Set[T]) Has(v T) bool
- func (s Set[T]) Remove(v T) bool
- func (s Set[T]) RemoveAll(elements ...T)
- func (s Set[T]) Union(other Set[T]) Set[T]
Functions ¶
func Contains ¶
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 ¶
func Filter ¶
func GetWriter ¶
func GetWriter(consumer func(string)) io.WriteCloser
GetWriter creates an io.Writer that will actually split by line and format by LogConsumer
func Remove ¶
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 ¶
StringToBool converts a string to a boolean ignoring errors
Types ¶
type SafeBuffer ¶
type SafeBuffer struct {
// contains filtered or unexported fields
}
SafeBuffer is a thread safe version of bytes.Buffer
func (*SafeBuffer) Bytes ¶
func (b *SafeBuffer) Bytes() []byte
Bytes is a thread safe version of bytes.Buffer::Bytes
func (*SafeBuffer) Read ¶
func (b *SafeBuffer) Read(p []byte) (n int, err error)
Read is a thread safe version of bytes.Buffer::Read
func (*SafeBuffer) RequireEventuallyContains ¶
func (b *SafeBuffer) RequireEventuallyContains(t testing.TB, v string)
RequireEventuallyContains is a thread safe eventual checker for the buffer content
func (*SafeBuffer) String ¶
func (b *SafeBuffer) String() string
String is a thread safe version of bytes.Buffer::String
func (*SafeBuffer) Write ¶
func (b *SafeBuffer) Write(p []byte) (n int, err error)
Write is a thread safe version of bytes.Buffer::Write
type Set ¶
type Set[T comparable] map[T]struct{}
func NewSet ¶
func NewSet[T comparable](v ...T) Set[T]
func (Set[T]) Add ¶
func (s Set[T]) Add(v T)
func (Set[T]) AddAll ¶
func (s Set[T]) AddAll(v ...T)
func (Set[T]) Clear ¶
func (s Set[T]) Clear()
func (Set[T]) Diff ¶
func (Set[T]) Elements ¶
func (s Set[T]) Elements() []T
func (Set[T]) Has ¶
func (Set[T]) Remove ¶
func (Set[T]) RemoveAll ¶
func (s Set[T]) RemoveAll(elements ...T)
func (Set[T]) Union ¶
Source Files ¶
durationutils.go safebuffer.go set.go slices.go stringutils.go writer.go
- Version
- v2.35.1 (latest)
- Published
- Apr 17, 2025
- Platform
- js/wasm
- Imports
- 9 packages
- Last checked
- 32 minutes ago –
Tools for package owners.