Documentation
¶
Index ¶
- Constants
- func ByteCountSI(b uint64) string
- func FilterCommonRootDirs(strSlice []string) []string
- func FilterSlicePfxStr(s []string) []string
- func InSlice[E comparable](item E, slice []E) booldeprecated
- func InSliceGlob(checkpath string, matchglobs []string, caseSensitive bool) bool
- func PosInSlice[E comparable](item E, slice []E) intdeprecated
- func RemoveFromStringSlice(item string, slice []string) []stringdeprecated
- func SlicesEqual[E comparable](a, b []E) booldeprecated
- func StringSliceUniq(sslice *[]string) *[]string
- func TypedSlice[Telem any](s []interface{}) (ret []Telem)
- func WriteToYaml(filePath string, object interface{}, perm fs.FileMode) error
- type Errors
- func (e *Errors) AddIf(err error) error
- func (e *Errors) AddMsgf(format string, param ...interface{}) error
- func (e *Errors) AddMsgs(message ...string)
- func (e *Errors) Append(errs *Errors) *Errors
- func (e *Errors) Err() error
- func (e *Errors) ErrString() string
- func (e *Errors) ErrStrings() []string
- type Map
- func (m Map[Tkey, Telem]) AttrSlice(selfun func(Telem) any) (rslice []any)
- func (m Map[Tkey, Telem]) FilterMapByKey(cmpfun func(Tkey) bool) (filteredMap Map[Tkey, Telem])
- func (m Map[Tkey, Telem]) FilterMapByVal(cmpfun func(Telem) bool) (filteredMap Map[Tkey, Telem])
- func (m Map[Tkey, Telem]) FilterMapToSlice(cmpfun func(Telem) bool) (filteredSlice []Telem)
- func (m *Map[Tkey, Telem]) ToSlice() (rslice []Telem)
- type TSimpleSLQ
- func (s *TSimpleSLQ) Append(item interface{}) interface{}
- func (s *TSimpleSLQ) Contains(item interface{}) bool
- func (s *TSimpleSLQ) CurrentItem() interface{}
- func (s *TSimpleSLQ) IndexOf(item interface{}) int
- func (s *TSimpleSLQ) InsertAt(item interface{}, pos int) interface{}
- func (s *TSimpleSLQ) ItemAt(pos int) interface{}
- func (s *TSimpleSLQ) Length() int
- func (s *TSimpleSLQ) Next() bool
- func (s *TSimpleSLQ) Pop() interface{}
- func (s *TSimpleSLQ) Prev() bool
- func (s *TSimpleSLQ) Push(item interface{}) interface{}
Constants ¶
const Version = "v0.5.0"
Version exposes the current package version.
Variables ¶
This section is empty.
Functions ¶
func ByteCountSI ¶
from https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/ ByteCountSI returns the "human readable" number of bytes in SI units (as a string)
func FilterCommonRootDirs ¶
FilterCommonRootDirs recursively filters out paths for which any higher root path exists in the same slice
func FilterSlicePfxStr ¶
FilterSlicePfxStr filters out all string items of which another slice member is a prefix, recursively by convention take the first element as the "pivot"
func InSlice
deprecated
func InSlice[E comparable](item E, slice []E) bool
InSlice returns true if item is in slice and false otherwise.
Deprecated: use the standard library slices.Contains(slice, item) directly. This is now a thin generic wrapper; callers should be migrated.
func InSliceGlob ¶ added in v0.5.0
InSliceGlob reports whether checkpath matches any of the glob patterns in matchglobs (using filepath.Match semantics). When caseSensitive is false, both the path and the patterns are lower-cased before matching. Typically callers pass filepath.Base(path) as checkpath.
func PosInSlice
deprecated
func PosInSlice[E comparable](item E, slice []E) int
PosInSlice returns the position of item in slice or -1 if not found.
Deprecated: use the standard library slices.Index(slice, item) directly. This is now a thin generic wrapper; callers should be migrated.
func RemoveFromStringSlice
deprecated
RemoveFromStringSlice removes the first occurrence of item and returns the resulting slice. If item is not present the original slice is returned.
Deprecated: use slices.Delete together with slices.Index (or slices.DeleteFunc) directly. This is now a thin wrapper; callers should be migrated. Note that, like slices.Delete, this modifies the backing array of the input slice.
func SlicesEqual
deprecated
func SlicesEqual[E comparable](a, b []E) bool
SlicesEqual tells whether a and b contain the same elements in the same order.
Deprecated: use the standard library slices.Equal(a, b) directly. This is now a thin generic wrapper; callers should be migrated.
func StringSliceUniq ¶ added in v0.5.0
func TypedSlice ¶ added in v0.5.0
func TypedSlice[Telem any](s []interface{}) (ret []Telem)
Types ¶
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
func (*Errors) ErrStrings ¶
type Map ¶ added in v0.5.0
type Map[Tkey comparable, Telem any] map[Tkey]Telem
func NewMap ¶ added in v0.5.0
func NewMap[Tkey comparable, Telem any]() Map[Tkey, Telem]
func (Map[Tkey, Telem]) AttrSlice ¶ added in v0.5.0
AttrSlice is used to get a slice of attributes of Telem that are selected into a user-provided struct using the provided function Unfortunately we cannot use generics in the function parameter, so we are stuck with the any return type, which is the same as interface{} Therefore this function returns []interface{} which we must convert. As a workaround we now do this conversion generic static function TypedSlice. More info here? (But behind paywall) https://itnext.io/generic-map-filter-and-reduce-in-go-3845781a591c
func (Map[Tkey, Telem]) FilterMapByKey ¶ added in v0.5.0
func (Map[Tkey, Telem]) FilterMapByVal ¶ added in v0.5.0
func (Map[Tkey, Telem]) FilterMapToSlice ¶ added in v0.5.0
we could use MapToSlice, but that would mean two loops...
type TSimpleSLQ ¶
type TSimpleSLQ struct {
// contains filtered or unexported fields
}
func NewSimpleSLQ ¶
func NewSimpleSLQ() *TSimpleSLQ
NewSimpleSLQ contsructor SimpleSLQ is a experimental, generic "Slice/List/Queue" hybrid like structure based on slice that implements:
Pop/Push, Next/Prev, IndexOf, ...
func (*TSimpleSLQ) Append ¶
func (s *TSimpleSLQ) Append(item interface{}) interface{}
func (*TSimpleSLQ) Contains ¶
func (s *TSimpleSLQ) Contains(item interface{}) bool
func (*TSimpleSLQ) CurrentItem ¶
func (s *TSimpleSLQ) CurrentItem() interface{}
func (*TSimpleSLQ) IndexOf ¶
func (s *TSimpleSLQ) IndexOf(item interface{}) int
func (*TSimpleSLQ) InsertAt ¶
func (s *TSimpleSLQ) InsertAt(item interface{}, pos int) interface{}
func (*TSimpleSLQ) ItemAt ¶
func (s *TSimpleSLQ) ItemAt(pos int) interface{}
func (*TSimpleSLQ) Length ¶
func (s *TSimpleSLQ) Length() int
func (*TSimpleSLQ) Next ¶
func (s *TSimpleSLQ) Next() bool
func (*TSimpleSLQ) Pop ¶
func (s *TSimpleSLQ) Pop() interface{}
func (*TSimpleSLQ) Prev ¶
func (s *TSimpleSLQ) Prev() bool
func (*TSimpleSLQ) Push ¶
func (s *TSimpleSLQ) Push(item interface{}) interface{}