Documentation ¶
Overview ¶
Package golang provides a set of functions and structures making Go more expressive and concise.
Index ¶
- func If[T any](condition bool, trueValue T) T
- func IfElse[T any](condition bool, trueValue, falseValue T) T
- func LazyIf[T any](condition bool, trueValueFunc func() T) T
- func LazyIfElse[T any](condition bool, trueValueFunc, falseValueFunc func() T) T
- func Ptr[T any](v T) *T
- func Zero[T any]() (result T)
- type Set
- func (s *Set[T]) Add(value ...T) *Set[T]
- func (s *Set[T]) Clone() *Set[T]
- func (s *Set[T]) Contains(value T) bool
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) IsImmutable() bool
- func (s *Set[T]) MarkImmutable() *Set[T]
- func (s *Set[T]) MergeWith(other *Set[T]) *Set[T]
- func (s *Set[T]) Remove(value T) *Set[T]
- func (s *Set[T]) Size() int
- func (s *Set[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LazyIf ¶
LazyIf returns the result of trueValueFunc if condition is true, otherwise the zero value of T. The function is only called if its result is needed.
func LazyIfElse ¶
LazyIfElse returns the result of trueValueFunc if condition is true, otherwise the result of falseValueFunc. The functions are only called if their result is needed.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a simple implementation of set of values of type T. It allows to mark the set as immutable to prevent further modifications. It is not thread-safe.
func NewSet ¶
func NewSet[T comparable](values ...T) *Set[T]
NewSet creates a new set with the given values.
func (*Set[T]) IsImmutable ¶
IsImmutable returns true if the set is immutable.
func (*Set[T]) MarkImmutable ¶
MarkImmutable marks the set as immutable.