gotilities

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 10 Imported by: 5

README

gotilities

Documentation

Index

Constants

View Source
const (
	JSONFancyPrefix = ""
	JSONFancyIndent = 2
)

Variables

View Source
var (
	ErrorEitherSideUndefined = errors.New("either side undefined")
)
View Source
var (
	ErrorInvalidMap = errors.New("no or invalid map passed")
)
View Source
var (
	ErrorParameterNil = errors.New("parameter invalid: nil passed")
)

Functions

func ByteEquals added in v0.0.2

func ByteEquals(b1, b2 byte, ignoreCase bool) bool

func ByteMust added in v0.0.2

func ByteMust(b byte, _ error) byte

func ByteToLower added in v0.0.2

func ByteToLower(b byte) byte

func ByteToUpper added in v0.0.2

func ByteToUpper(b byte) byte

func BytesAny added in v0.0.2

func BytesAny(slice []byte, method SearchMethod, predicate func(i int, b byte) bool) bool

func BytesChunk added in v0.0.2

func BytesChunk(slice []byte, chunkSize int) [][]byte

func BytesCopy added in v0.0.2

func BytesCopy(slice []byte) []byte

func BytesDeleteOrdered added in v0.0.2

func BytesDeleteOrdered(slice []byte, index int) []byte

1.000.000 elements -> ~224s

func BytesDeleteTruncated added in v0.0.2

func BytesDeleteTruncated(slice []byte, index int) []byte

func BytesDeleteUnordered added in v0.0.2

func BytesDeleteUnordered(slice []byte, index int) []byte

1.000.000 elements -> ~0.06ns

func BytesFilter added in v0.0.2

func BytesFilter(slice []byte, predicate func(i int, b byte) bool) []byte

func BytesFirst added in v0.0.2

func BytesFirst(slice []byte, method SearchMethod, predicate func(i int, b byte) bool) (int, byte, bool)

func BytesFlatten added in v0.0.2

func BytesFlatten(slices ...[]byte) []byte

func BytesForeach added in v0.0.2

func BytesForeach(slice []byte, action func(i int, b byte))

func BytesFromInterfaces added in v0.0.4

func BytesFromInterfaces(slice []interface{}) []byte

func BytesIncludes added in v0.0.2

func BytesIncludes(slice []byte, method SearchMethod, target byte, ignoreCase bool) bool

func BytesMap added in v0.0.4

func BytesMap(slice []byte, mappingFunc func(i int, b byte) interface{}) []interface{}

func BytesMust added in v0.0.2

func BytesMust(slice []byte, _ error) []byte

func BytesOperate added in v0.0.2

func BytesOperate(slice []byte, operation func(i int, b byte, curr float64) float64) float64

func BytesSingleton added in v0.0.2

func BytesSingleton(b byte) []byte

func BytesToInterfaces added in v0.0.4

func BytesToInterfaces(slice []byte) []interface{}

func BytesTrim added in v0.0.2

func BytesTrim(b ...byte) []byte

func FloatChecksum added in v0.0.2

func FloatChecksum(f float64) int

func FloatMust added in v0.0.2

func FloatMust(f float64, _ error) float64

func Floats32Conversion added in v0.0.2

func Floats32Conversion(slice []float32) []float64

func FloatsAny added in v0.0.2

func FloatsAny(slice []float64, method SearchMethod, predicate func(i int, f float64) bool) bool

func FloatsChunk added in v0.0.2

func FloatsChunk(slice []float64, chunkSize int) [][]float64

func FloatsCopy added in v0.0.2

func FloatsCopy(slice []float64) []float64

func FloatsDeleteOrdered added in v0.0.2

func FloatsDeleteOrdered(slice []float64, index int) []float64

1.000.000 elements -> ~224s

func FloatsDeleteTruncated added in v0.0.2

func FloatsDeleteTruncated(slice []float64, index int) []float64

func FloatsDeleteUnordered added in v0.0.2

func FloatsDeleteUnordered(slice []float64, index int) []float64

1.000.000 elements -> ~0.06ns

func FloatsFilter added in v0.0.2

func FloatsFilter(slice []float64, predicate func(i int, f float64) bool) []float64

func FloatsFirst added in v0.0.2

func FloatsFirst(slice []float64, method SearchMethod, predicate func(i int, f float64) bool) (int, float64, bool)

func FloatsFlatten added in v0.0.2

func FloatsFlatten(slices ...[]float64) []float64

func FloatsForeach added in v0.0.2

func FloatsForeach(slice []float64, action func(i int, f float64))

func FloatsFromInterfaces added in v0.0.4

func FloatsFromInterfaces(slice []interface{}) []float64

func FloatsIncludes added in v0.0.2

func FloatsIncludes(slice []float64, method SearchMethod, target float64) bool

func FloatsMap added in v0.0.4

func FloatsMap(slice []float64, mappingFunc func(i int, f float64) interface{}) []interface{}

func FloatsMust added in v0.0.4

func FloatsMust(slice []float64, _ error) []float64

func FloatsOperate added in v0.0.2

func FloatsOperate(slice []float64, operation func(i int, f float64, curr float64) float64) float64

func FloatsSingleton added in v0.0.2

func FloatsSingleton(f float64) []float64

func FloatsSortAscending added in v0.0.2

func FloatsSortAscending(slice []float64) []float64

func FloatsSortDescending added in v0.0.2

func FloatsSortDescending(slice []float64) []float64

func FloatsToInterfaces added in v0.0.4

func FloatsToInterfaces(slice []float64) []interface{}

func FloatsTotalAverage added in v0.0.2

func FloatsTotalAverage(slice []float64) int

func FloatsTotalDiff added in v0.0.2

func FloatsTotalDiff(slice []float64) float64

func FloatsTotalFrac added in v0.0.2

func FloatsTotalFrac(slice []float64) float64

func FloatsTotalProd added in v0.0.2

func FloatsTotalProd(slice []float64) float64

func FloatsTotalSum added in v0.0.2

func FloatsTotalSum(slice []float64) float64

func IntChecksum added in v0.0.2

func IntChecksum(i int) int

func IntMust added in v0.0.2

func IntMust(i int, _ error) int

func InterfaceMust added in v0.0.2

func InterfaceMust(v interface{}, _ error) interface{}

func InterfacesAny added in v0.0.2

func InterfacesAny(slice []interface{}, method SearchMethod, predicate func(i int, s interface{}) bool) bool

func InterfacesChunk added in v0.0.2

func InterfacesChunk(slice []interface{}, chunkSize int) [][]interface{}

func InterfacesCopy added in v0.0.2

func InterfacesCopy(slice []interface{}) []interface{}

func InterfacesDeleteOrdered added in v0.0.2

func InterfacesDeleteOrdered(slice []interface{}, index int) []interface{}

1.000.000 elements -> ~224s

func InterfacesDeleteTruncated added in v0.0.2

func InterfacesDeleteTruncated(slice []interface{}, index int) []interface{}

func InterfacesDeleteUnordered added in v0.0.2

func InterfacesDeleteUnordered(slice []interface{}, index int) []interface{}

1.000.000 elements -> ~0.06ns

func InterfacesFilter added in v0.0.2

func InterfacesFilter(slice []interface{}, predicate func(i int, v interface{}) bool) []interface{}

func InterfacesFirst added in v0.0.2

func InterfacesFirst(slice []interface{}, method SearchMethod, predicate func(i int, v interface{}) bool) (int, interface{}, bool)

func InterfacesFlatten added in v0.0.2

func InterfacesFlatten(slices ...[]interface{}) []interface{}

func InterfacesForeach added in v0.0.2

func InterfacesForeach(slice []interface{}, action func(i int, v interface{}))

func InterfacesIncludes added in v0.0.2

func InterfacesIncludes(slice []interface{}, method SearchMethod, target interface{}) bool

func InterfacesMust added in v0.0.4

func InterfacesMust(slice []interface{}, _ error) []interface{}

func InterfacesOperate added in v0.0.2

func InterfacesOperate(slice []interface{}, operation func(i int, v interface{}, curr float64) float64) float64

func InterfacesSingleton added in v0.0.2

func InterfacesSingleton(v interface{}) []interface{}

func Ints16Conversion added in v0.0.2

func Ints16Conversion(slice []int16) []int

func Ints32Conversion added in v0.0.2

func Ints32Conversion(slice []int32) []int

func Ints64Conversion added in v0.0.2

func Ints64Conversion(slice []int64) []int

func Ints8Conversion added in v0.0.2

func Ints8Conversion(slice []int8) []int

func IntsAny added in v0.0.2

func IntsAny(slice []int, method SearchMethod, predicate func(i int, v int) bool) bool

func IntsChunk added in v0.0.2

func IntsChunk(slice []int, chunkSize int) [][]int

func IntsCopy added in v0.0.2

func IntsCopy(slice []int) []int

func IntsDeleteOrdered added in v0.0.2

func IntsDeleteOrdered(slice []int, index int) []int

1.000.000 elements -> ~224s

func IntsDeleteTruncated added in v0.0.2

func IntsDeleteTruncated(slice []int, index int) []int

func IntsDeleteUnordered added in v0.0.2

func IntsDeleteUnordered(slice []int, index int) []int

1.000.000 elements -> ~0.06ns

func IntsFilter added in v0.0.2

func IntsFilter(slice []int, predicate func(i int, v int) bool) []int

func IntsFirst added in v0.0.2

func IntsFirst(slice []int, method SearchMethod, predicate func(i int, v int) bool) (int, int, bool)

func IntsFlatten added in v0.0.2

func IntsFlatten(slices ...[]int) []int

func IntsForeach added in v0.0.2

func IntsForeach(slice []int, action func(i int, v int))

func IntsFromInterfaces added in v0.0.4

func IntsFromInterfaces(slice []interface{}) []int

func IntsIncludes added in v0.0.2

func IntsIncludes(slice []int, method SearchMethod, target int) bool

func IntsMap added in v0.0.4

func IntsMap(slice []int, mappingFunc func(i int, v int) interface{}) []interface{}

func IntsMust added in v0.0.4

func IntsMust(slice []int, _ error) []int

func IntsOperate added in v0.0.2

func IntsOperate(slice []int, operation func(i int, v int, curr float64) float64) float64

func IntsSingleton added in v0.0.2

func IntsSingleton(i int) []int

func IntsSortAscending added in v0.0.2

func IntsSortAscending(slice []int) []int

func IntsSortDescending added in v0.0.2

func IntsSortDescending(slice []int) []int

func IntsToInterfaces added in v0.0.4

func IntsToInterfaces(slice []int) []interface{}

func IntsTotalAverage added in v0.0.2

func IntsTotalAverage(slice []int) int

func IntsTotalDiff added in v0.0.2

func IntsTotalDiff(slice []int) int

func IntsTotalFrac added in v0.0.2

func IntsTotalFrac(slice []int) float64

func IntsTotalProd added in v0.0.2

func IntsTotalProd(slice []int) int

func IntsTotalSum added in v0.0.2

func IntsTotalSum(slice []int) int

func JSONFancyMarshal added in v0.0.2

func JSONFancyMarshal(v interface{}) ([]byte, error)

func JSONIndent added in v0.0.2

func JSONIndent(v interface{}, prefix string, indent int) ([]byte, error)

func MapGeneric added in v0.0.4

func MapGeneric(m interface{}) (map[interface{}]interface{}, error)

func MapKeys added in v0.0.4

func MapKeys(m interface{}) ([]interface{}, error)

func MapMust added in v0.0.4

func MapMust(m map[interface{}]interface{}, _ error) map[interface{}]interface{}

func MapValidate added in v0.0.4

func MapValidate(m interface{}) error

func MapValues added in v0.0.4

func MapValues(m interface{}) ([]interface{}, error)

func RuneEquals added in v0.0.2

func RuneEquals(r1, r2 rune, ignoreCase bool) bool

func RuneMust added in v0.0.2

func RuneMust(r rune, _ error) rune

func RunesAny added in v0.0.2

func RunesAny(slice []rune, method SearchMethod, predicate func(i int, r rune) bool) bool

func RunesChunk added in v0.0.2

func RunesChunk(slice []rune, chunkSize int) [][]rune

func RunesCopy added in v0.0.2

func RunesCopy(slice []rune) []rune

func RunesDeleteOrdered added in v0.0.2

func RunesDeleteOrdered(slice []rune, index int) []rune

1.000.000 elements -> ~224s

func RunesDeleteTruncated added in v0.0.2

func RunesDeleteTruncated(slice []rune, index int) []rune

func RunesDeleteUnordered added in v0.0.2

func RunesDeleteUnordered(slice []rune, index int) []rune

1.000.000 elements -> ~0.06ns

func RunesFilter added in v0.0.2

func RunesFilter(slice []rune, predicate func(i int, r rune) bool) []rune

func RunesFirst added in v0.0.2

func RunesFirst(slice []rune, method SearchMethod, predicate func(i int, r rune) bool) (int, rune, bool)

func RunesFlatten added in v0.0.2

func RunesFlatten(slices ...[]rune) []rune

func RunesForeach added in v0.0.2

func RunesForeach(slice []rune, action func(i int, r rune))

func RunesFromInterfaces added in v0.0.4

func RunesFromInterfaces(slice []interface{}) []rune

func RunesIncludes added in v0.0.2

func RunesIncludes(slice []rune, method SearchMethod, target rune, ignoreCase bool) bool

func RunesMap added in v0.0.4

func RunesMap(slice []rune, mappingFunc func(i int, r rune) interface{}) []interface{}

func RunesMust added in v0.0.4

func RunesMust(slice []rune, _ error) []rune

func RunesOperate added in v0.0.2

func RunesOperate(slice []rune, operation func(i int, r rune, curr float64) float64) float64

func RunesSingleton added in v0.0.2

func RunesSingleton(r rune) []rune

func RunesToInterfaces added in v0.0.4

func RunesToInterfaces(slice []rune) []interface{}

func RunesTotalLength added in v0.0.2

func RunesTotalLength(slice []rune) int

func StringEquals added in v0.0.2

func StringEquals(s1, s2 string, ignoreCase bool) bool

func StringHasPrefix added in v0.0.2

func StringHasPrefix(s, prefix string, ignoreCase bool) bool

func StringHasSuffix added in v0.0.2

func StringHasSuffix(s1, suffix string, ignoreCase bool) bool

func StringIncludes added in v0.0.2

func StringIncludes(s, substring string, ignoreCase bool) bool

func StringIsBlank added in v0.0.2

func StringIsBlank(s string) bool

func StringIsURL added in v0.0.3

func StringIsURL(s string) bool

func StringMust added in v0.0.2

func StringMust(s string, _ error) string

func StringRepeat added in v0.0.2

func StringRepeat(s string, times int) string

func StringTrim added in v0.0.2

func StringTrim(s string) string

func StringsAny added in v0.0.2

func StringsAny(slice []string, method SearchMethod, predicate func(i int, s string) bool) bool

func StringsChunk added in v0.0.2

func StringsChunk(slice []string, chunkSize int) [][]string

func StringsCopy added in v0.0.2

func StringsCopy(slice []string) []string

func StringsDeleteOrdered added in v0.0.2

func StringsDeleteOrdered(slice []string, index int) []string

1.000.000 elements -> ~224s

func StringsDeleteTruncated added in v0.0.2

func StringsDeleteTruncated(slice []string, index int) []string

func StringsDeleteUnordered added in v0.0.2

func StringsDeleteUnordered(slice []string, index int) []string

1.000.000 elements -> ~0.06ns

func StringsFilter added in v0.0.2

func StringsFilter(slice []string, predicate func(i int, s string) bool) []string

func StringsFirst added in v0.0.2

func StringsFirst(slice []string, method SearchMethod, predicate func(i int, s string) bool) (int, string, bool)

func StringsFlatten added in v0.0.2

func StringsFlatten(slices ...[]string) []string

func StringsForeach added in v0.0.2

func StringsForeach(slice []string, action func(i int, s string))

func StringsFromInterfaces added in v0.0.4

func StringsFromInterfaces(slice []interface{}) []string

func StringsIncludes added in v0.0.2

func StringsIncludes(slice []string, method SearchMethod, target string, ignoreCase bool) bool

func StringsMap added in v0.0.4

func StringsMap(slice []string, mappingFunc func(i int, s string) interface{}) []interface{}

func StringsMust added in v0.0.4

func StringsMust(slice []string, _ error) []string

func StringsOperate added in v0.0.2

func StringsOperate(slice []string, operation func(i int, s string, curr float64) float64) float64

func StringsSingleton added in v0.0.2

func StringsSingleton(s string) []string

func StringsSortAlphabetically added in v0.0.2

func StringsSortAlphabetically(slice []string) []string

func StringsSortAscending added in v0.0.2

func StringsSortAscending(slice []string) []string

func StringsSortByLengthAscending added in v0.0.2

func StringsSortByLengthAscending(slice []string) []string

func StringsSortByLengthDescending added in v0.0.2

func StringsSortByLengthDescending(slice []string) []string

func StringsSortDescending added in v0.0.2

func StringsSortDescending(slice []string) []string

func StringsToInterfaces added in v0.0.4

func StringsToInterfaces(slice []string) []interface{}

func StringsTotalLength added in v0.0.2

func StringsTotalLength(slice []string) int

func Struct added in v0.0.5

func Struct(v interface{}) (reflect.Type, reflect.Value, error)

func StructFilter added in v0.0.5

func StructFilter(v interface{}, predicate func(i int, field reflect.StructField, value reflect.Value) bool) (map[*reflect.StructField]reflect.Value, error)

func StructForeach added in v0.0.5

func StructForeach(v interface{}, action func(i int, field reflect.StructField, value reflect.Value)) error

func TuplesAny added in v0.0.2

func TuplesAny(slice []Tuple, method SearchMethod, predicate func(i int, s Tuple) bool) bool

func TuplesChunk added in v0.0.2

func TuplesChunk(slice []Tuple, chunkSize int) [][]Tuple

func TuplesForeach added in v0.0.2

func TuplesForeach(slice []Tuple, action func(i int, t Tuple))

func TuplesIncludes added in v0.0.2

func TuplesIncludes(slice []Tuple, method SearchMethod, target Tuple) bool

func TuplesMap added in v0.0.4

func TuplesMap(slice []Tuple, mappingFunc func(i int, t Tuple) interface{}) []interface{}

func TuplesOperate added in v0.0.2

func TuplesOperate(slice []Tuple, operation func(i int, t Tuple, curr float64) float64) float64

func TuplesToInterfaces added in v0.0.4

func TuplesToInterfaces(slice []Tuple) []interface{}

func TuplesToMap added in v0.0.2

func TuplesToMap(tuples ...Tuple) map[interface{}]interface{}

Types

type Either added in v0.0.2

type Either interface {
	Side() Side

	Left() (interface{}, error)
	Right() (interface{}, error)
}

func EitherLeft added in v0.0.2

func EitherLeft(left interface{}) Either

func EitherMust added in v0.0.4

func EitherMust(e Either, _ error) Either

func EitherRight added in v0.0.2

func EitherRight(right interface{}) Either

type SearchMethod added in v0.0.2

type SearchMethod string
const (
	SearchMethodDefault      SearchMethod = "iterate"
	SearchMethodBinarySearch              = "binarySearch"
)

type Side added in v0.0.3

type Side string
const (
	SideLeft  Side = "left"
	SideRight Side = "right"
)

func (Side) IsLeft added in v0.0.3

func (side Side) IsLeft() bool

func (Side) IsRight added in v0.0.3

func (side Side) IsRight() bool

func (Side) Opposite added in v0.0.3

func (side Side) Opposite() Side

type StringSortSliceAlphabetically added in v0.0.2

type StringSortSliceAlphabetically []string

func (StringSortSliceAlphabetically) Len added in v0.0.2

func (StringSortSliceAlphabetically) Less added in v0.0.2

func (sort StringSortSliceAlphabetically) Less(i, j int) bool

func (StringSortSliceAlphabetically) Swap added in v0.0.2

func (sort StringSortSliceAlphabetically) Swap(i, j int)

type StringSortSliceLengthAscending added in v0.0.2

type StringSortSliceLengthAscending []string

func (StringSortSliceLengthAscending) Len added in v0.0.2

func (StringSortSliceLengthAscending) Less added in v0.0.2

func (sort StringSortSliceLengthAscending) Less(i, j int) bool

func (StringSortSliceLengthAscending) Swap added in v0.0.2

func (sort StringSortSliceLengthAscending) Swap(i, j int)

type StringSortSliceLengthDescending added in v0.0.2

type StringSortSliceLengthDescending []string

func (StringSortSliceLengthDescending) Len added in v0.0.2

func (StringSortSliceLengthDescending) Less added in v0.0.2

func (sort StringSortSliceLengthDescending) Less(i, j int) bool

func (StringSortSliceLengthDescending) Swap added in v0.0.2

func (sort StringSortSliceLengthDescending) Swap(i, j int)

type Switch added in v0.0.3

type Switch interface {
	Side() Side

	Current() interface{}
	Left() interface{}
	Right() interface{}

	Toggle() (interface{}, Side)
}

func NewSwitch added in v0.0.3

func NewSwitch(side Side, left, right interface{}) Switch

type Tuple added in v0.0.2

type Tuple interface {
	First() interface{}
	Second() interface{}
}

func NewTuple added in v0.0.2

func NewTuple(first, second interface{}) Tuple

func TupleMust added in v0.0.2

func TupleMust(t Tuple, _ error) Tuple

func TuplesCopy added in v0.0.2

func TuplesCopy(slice []Tuple) []Tuple

func TuplesDeleteOrdered added in v0.0.2

func TuplesDeleteOrdered(slice []Tuple, index int) []Tuple

1.000.000 elements -> ~224s

func TuplesDeleteTruncated added in v0.0.2

func TuplesDeleteTruncated(slice []Tuple, index int) []Tuple

func TuplesDeleteUnordered added in v0.0.2

func TuplesDeleteUnordered(slice []Tuple, index int) []Tuple

1.000.000 elements -> ~0.06ns

func TuplesFilter added in v0.0.2

func TuplesFilter(slice []Tuple, predicate func(i int, t Tuple) bool) []Tuple

func TuplesFirst added in v0.0.2

func TuplesFirst(slice []Tuple, method SearchMethod, predicate func(i int, t Tuple) bool) (int, Tuple, bool)

func TuplesFlatten added in v0.0.2

func TuplesFlatten(slices ...[]Tuple) []Tuple

func TuplesFromInterfaces added in v0.0.4

func TuplesFromInterfaces(slice []interface{}) []Tuple

func TuplesFromMap added in v0.0.2

func TuplesFromMap(m map[interface{}]interface{}) []Tuple

func TuplesMust added in v0.0.4

func TuplesMust(slice []Tuple, _ error) []Tuple

func TuplesSingleton added in v0.0.2

func TuplesSingleton(t Tuple) []Tuple

Jump to

Keyboard shortcuts

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