w

package
v1.2.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PosRight = iota
	PosLeft
	PosCenter
)

Variables

View Source
var (
	//nolint:revive
	QueueFull = errors.New("queue is full")
	//nolint:revive
	QueueNull = errors.New("queue is null")
)
View Source
var ErrStopping = errors.New("program stopping")
View Source
var ExitFunc = os.Exit
View Source
var NopInterrupt = func(err error) {}

Functions

func AddFuncMaps added in v1.1.4

func AddFuncMaps(funcName string, f interface{})

func DefaultNumber added in v1.2.0

func DefaultNumber[T Number](vals ...T) T

func DefaultPointer added in v1.2.0

func DefaultPointer[T any](vals ...*T) *T

func DefaultString added in v1.2.0

func DefaultString(vals ...string) string

func E

func E[T any](_ T, err error) error

func Filter

func Filter[T any](old []T, f func(item T) bool) []T

func Find

func Find[T any](s []T, t T, compare func(a, b T) bool) int

func Has

func Has[T any](s []T, t T, compare func(a, b T) bool) bool

func Include

func Include[T comparable](s []T, t T) bool

func Index

func Index[T comparable](s []T, t T) int

func Interfaces

func Interfaces[T any](objs []T) []interface{}

func JSONStringer

func JSONStringer(v any) fmt.Stringer

func Limit

func Limit[T any](s []T, limit int, hidePosition int, manySuffix ...T) []T

func M

func M[T any](v T, err error) T

func Map

func Map[S any, T any](old []S, f func(item S) T) []T

func Merge added in v1.2.3

func Merge[M ~map[K]V, K comparable, V any](maps ...M) M

func NewStringer

func NewStringer(stringer func() string) fmt.Stringer

func P

func P[T any](o T) *T

func Pipe added in v1.2.8

func Pipe[sT any, dT any](v sT, e error) func(func(sT) (dT, error)) (dT, error)

func StringEqual added in v1.1.2

func StringEqual(a, b string) bool

func T added in v1.2.8

func T[vT any](expr bool, trueVal, falseVal vT) vT

Types

type Comparable added in v1.1.5

type Comparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64 | ~string
}

type Equal added in v1.2.3

type Equal[T any] interface {
	Equal(T) bool
}

type Group added in v1.1.6

type Group run.Group

func (*Group) Add added in v1.1.6

func (g *Group) Add(execute func() error, interrupt func(error))

func (*Group) Run added in v1.1.6

func (g *Group) Run() error

type Number added in v1.2.0

type Number interface {
	~int8 | ~int16 | ~int32 | ~int64 |
		~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float64 | ~float32 | ~int | ~uint
}

type OneOrMore added in v1.1.2

type OneOrMore[T any] []T

OneOrMore represents a value that can either be a string or an array of strings. Mainly here for serialization purposes

func (OneOrMore[T]) Contains added in v1.1.2

func (s OneOrMore[T]) Contains(value T) bool

Contains returns true when the value is contained in the slice

func (OneOrMore[T]) MarshalJSON added in v1.1.2

func (s OneOrMore[T]) MarshalJSON() ([]byte, error)

MarshalJSON converts this string or array to a JSON array or JSON string

func (OneOrMore[T]) MarshalYAML added in v1.1.2

func (s OneOrMore[T]) MarshalYAML() (interface{}, error)

func (*OneOrMore[T]) UnmarshalJSON added in v1.1.2

func (s *OneOrMore[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals this string or array object from a JSON array or signal JSON value

func (*OneOrMore[T]) UnmarshalYAML added in v1.1.2

func (s *OneOrMore[T]) UnmarshalYAML(value *yaml.Node) error

type RingQueue added in v1.1.14

type RingQueue[T any] struct {
	// contains filtered or unexported fields
}

func NewRingQueue added in v1.1.14

func NewRingQueue[T any](n int) *RingQueue[T]

func (*RingQueue[T]) Do added in v1.1.14

func (r *RingQueue[T]) Do(f func(a T))

func (*RingQueue[T]) Get added in v1.1.14

func (r *RingQueue[T]) Get() (T, error)

func (*RingQueue[T]) Len added in v1.1.14

func (r *RingQueue[T]) Len() int

func (*RingQueue[T]) List added in v1.1.14

func (r *RingQueue[T]) List() []T

func (*RingQueue[T]) Put added in v1.1.14

func (r *RingQueue[T]) Put(val T) error

func (*RingQueue[T]) Remove added in v1.1.14

func (r *RingQueue[T]) Remove(f func(a T) bool)

type SortedMap added in v1.1.5

type SortedMap[K Comparable, V any] []SortedMapItem[K, V]

func NewSortedMap added in v1.1.5

func NewSortedMap[K Comparable, V any](kvs ...map[K]V) SortedMap[K, V]

func (SortedMap[K, V]) Len added in v1.1.5

func (s SortedMap[K, V]) Len() int

func (SortedMap[K, V]) Less added in v1.1.5

func (s SortedMap[K, V]) Less(i, j int) bool

func (SortedMap[K, V]) Swap added in v1.1.5

func (s SortedMap[K, V]) Swap(i, j int)

type SortedMapItem added in v1.1.5

type SortedMapItem[K Comparable, V any] struct {
	Key   K
	Value V
}

type Stringer

type Stringer struct {
	// contains filtered or unexported fields
}

func (Stringer) String

func (s Stringer) String() string

type Template added in v1.1.3

type Template struct {
	// contains filtered or unexported fields
}

func NewHTMLTemplate added in v1.2.6

func NewHTMLTemplate(raw string) (*Template, error)

func NewTextTemplate added in v1.2.6

func NewTextTemplate(raw string) (*Template, error)

func (*Template) DefinedTemplates added in v1.1.3

func (t *Template) DefinedTemplates() string

func (*Template) Execute added in v1.1.3

func (t *Template) Execute(wr io.Writer, data any) error

func (*Template) ExecuteTemplate added in v1.1.3

func (t *Template) ExecuteTemplate(wr io.Writer, name string, data any) error

func (*Template) ExecuteToString added in v1.2.6

func (t *Template) ExecuteToString(data any) (string, error)

func (Template) MarshalJSON added in v1.1.3

func (t Template) MarshalJSON() ([]byte, error)

func (Template) MarshalYAML added in v1.1.3

func (t Template) MarshalYAML() (interface{}, error)

func (*Template) Name added in v1.1.3

func (t *Template) Name() string

func (*Template) UnmarshalJSON added in v1.1.3

func (t *Template) UnmarshalJSON(data []byte) (err error)

func (*Template) UnmarshalYAML added in v1.1.3

func (t *Template) UnmarshalYAML(value *yaml.Node) (err error)

type TemplateHandler added in v1.1.3

type TemplateHandler interface {
	Name() string
	ExecuteTemplate(wr io.Writer, name string, data any) error
	Execute(wr io.Writer, data any) error
	DefinedTemplates() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL