core

package module
v1.28.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 12 Imported by: 4

README

core

Core features of atrico libraries

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneWithDefaults added in v1.23.0

func CloneWithDefaults[T any](original, defaults T, skip ...string) (result T)

Clone an object, filling unset fields with defaults

func ConvertSlice

func ConvertSlice[TI, TO any](input []TI, convert func(in TI) TO) (output []TO)

Convert a slice of one type to another

func DisplayMultiline

func DisplayMultiline(obj StringerMl, params ...interface{})

func DisplaySliceAsSeparatedString added in v1.27.1

func DisplaySliceAsSeparatedString[T any](values []T, separator string) string

func DownCastSlice added in v1.20.0

func DownCastSlice[T any](input []interface{}) (output []T, err error)

Down Cast a slice of any type to interface{}

func FdisplayMultiline

func FdisplayMultiline(writer io.Writer, obj StringerMl, params ...interface{})

func GoId

func GoId() int

Id of go routine Use for debugging only

func Max added in v1.24.0

func Max[T constraints.Ordered](a, b T) T

func Min added in v1.24.0

func Min[T constraints.Ordered](a, b T) T

func Must added in v1.20.2

func Must[T any](action func() (T, error)) (result T)

Convert error return function into direct return with panic

func Must1 added in v1.22.2

func Must1[T, P1 any](action func(P1) (T, error), p1 P1) (result T)

func Must2 added in v1.22.2

func Must2[T, P1, P2 any](action func(P1, P2) (T, error), p1 P1, p2 P2) (result T)

func Must3 added in v1.22.2

func Must3[T, P1, P2, P3 any](action func(P1, P2, P3) (T, error), p1 P1, p2 P2, p3 P3) (result T)

func Must4 added in v1.22.2

func Must4[T, P1, P2, P3, P4 any](action func(P1, P2, P3, P4) (T, error), p1 P1, p2 P2, p3 P3, p4 P4) (result T)

func MustNotError added in v1.25.1

func MustNotError(action func() error)

Convert error into panic (no return)

func MustNotError1 added in v1.25.1

func MustNotError1[P1 any](action func(P1) error, p1 P1)

func MustNotError2 added in v1.25.1

func MustNotError2[P1, P2 any](action func(P1, P2) error, p1 P1, p2 P2)

func MustNotError3 added in v1.25.1

func MustNotError3[P1, P2, P3 any](action func(P1, P2, P3) error, p1 P1, p2 P2, p3 P3)

func MustNotError4 added in v1.25.1

func MustNotError4[P1, P2, P3, P4 any](action func(P1, P2, P3, P4) error, p1 P1, p2 P2, p3 P3, p4 P4)

func ReadBytes added in v1.17.0

func ReadBytes(reader io.Reader, buffer []byte) (n int, err error)

Multiple pass reader Copes with io.Reader giving less bytes than requested

func ReadChannelAsSlice added in v1.24.0

func ReadChannelAsSlice[T any](ch <-chan T) []T

Read a channel into a slice

func ReadChannelAsSliceN added in v1.24.0

func ReadChannelAsSliceN[T any](ch <-chan T, maxLen int) []T

Read a channel into a slice Will return no more than maxLen maxlen = -1 means no limit

func ReadNBytes added in v1.17.1

func ReadNBytes(reader io.Reader, count int) (buffer []byte, err error)

Read an absolute number of bytes from a reader

func SliceContains added in v1.21.0

func SliceContains[T comparable](list []T, item T) bool

func UpCastSlice added in v1.20.0

func UpCastSlice[T any](input []T) (output []interface{})

Up Cast a slice of any type to interface{}

Types

type CachedValue added in v1.20.0

type CachedValue[T any] interface {
	GetValue() T
	Reset()
}

func NewCachedValue added in v1.20.0

func NewCachedValue[T any](creator func() T) CachedValue[T]

type StringFilter added in v1.28.2

type StringFilter interface {
	// Is this string included (matches filter criteria)
	IsIncluded(item string) bool
	// Filter this slice
	Filter(original []string) (filtered []string)
}

StringFilter strings based on regex include and exclude

var AcceptAllFilter StringFilter = defaultFilter(true)
var RejectAllFilter StringFilter = defaultFilter(false)

func NewFilter added in v1.28.0

func NewFilter(include []string, exclude []string) StringFilter

type StringerMl

type StringerMl interface {
	// Representation of object as multiple lines
	StringMl(params ...interface{}) []string
}

Multiline version of Stringer

type UniqueNamesContext added in v1.18.0

type UniqueNamesContext map[string]int

func (*UniqueNamesContext) Unique added in v1.18.0

func (c *UniqueNamesContext) Unique(name string) (uniqueName string)

Directories

Path Synopsis
collection
set
numbers
int

Jump to

Keyboard shortcuts

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