gogenutils

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: EUPL-1.2 Imports: 7 Imported by: 4

README

gogenutils

General utility functions for go (as a go package)

Documentation

Index

Constants

View Source
const Version = "v0.4.0"

Version exposes the current package version.

Variables

This section is empty.

Functions

func ByteCountSI

func ByteCountSI(b uint64) string

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

func FilterCommonRootDirs(strSlice []string) []string

FilterCommonRootDirs recursively filters out paths for which any higher root path exists in the same slice

func FilterSlicePfxStr

func FilterSlicePfxStr(s []string) []string

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

func InSlice(item interface{}, slice interface{}) bool

InSlice returns true if item is in list and false otherwise

func PosInSlice

func PosInSlice(item interface{}, slice interface{}) int

PosInSlice returns the position of item in slice or -1 if not found

func RemoveFromStringSlice

func RemoveFromStringSlice(item string, slice []string) []string

RemoveFromStringSlice removes the itmen and returns a new slice

func SlicesEqual

func SlicesEqual(a, b interface{}) bool

Equal tells whether a and b contain the same elements in the same order (!) A nil argument is equivalent to an empty slice.

func WriteToYaml

func WriteToYaml(filePath string, object interface{}, perm fs.FileMode) error

WriteToYaml writes given object to yaml

Types

type Errors

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

func NewErrors

func NewErrors() *Errors

func (*Errors) AddIf

func (e *Errors) AddIf(err error) error

func (*Errors) AddMsgf

func (e *Errors) AddMsgf(format string, param ...interface{}) error

func (*Errors) AddMsgs

func (e *Errors) AddMsgs(message ...string)

func (*Errors) Append added in v0.4.0

func (e *Errors) Append(errs *Errors) *Errors

func (*Errors) Err

func (e *Errors) Err() error

func (*Errors) ErrString

func (e *Errors) ErrString() string

func (*Errors) ErrStrings

func (e *Errors) ErrStrings() []string

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{}

Jump to

Keyboard shortcuts

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