utilities

package module
v0.0.0-...-60d7401 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 6 Imported by: 1

README

utilities

A collection of my commonly used utilities

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCharAround

func AddCharAround(target string, char rune) string

AddCharAround adds `char` before and after `target`

func ContainsAny

func ContainsAny[K comparable](arrA []K, arrB []K) bool

ContainsAny, returns if ANY elements from arrA exist in arrB

func FilterElementsMatchingCondition

func FilterElementsMatchingCondition[V CompatibleArrayTypes](inputArr [][]V, matchFunc func(V) bool) [][]V

FilterElementsMatchingCondition, removes any elements from `inputArr` that return "true" from `matchFunc`

func GetBigEndianBytes

func GetBigEndianBytes(data interface{}) []byte

func GetCorrectEndianBytes

func GetCorrectEndianBytes(data interface{}) []byte

func GetCorrectEndianTimestamp

func GetCorrectEndianTimestamp(leastSignificantBytes []byte) uint64

func GetCorrectEndianUint32

func GetCorrectEndianUint32(bs []byte) uint32

func GetCorrectEndianUint64

func GetCorrectEndianUint64(bs []byte) uint64

func GetLittleEndianBytes

func GetLittleEndianBytes(data interface{}) []byte

func GetLowerChars

func GetLowerChars(s string) string

func GetUpperChars

func GetUpperChars(s string) string

func IndexOf

func IndexOf[K comparable](target K, array []K) int

IndexOf returns the FIRST occurrence of `target` in `array`

NOTE: Use `IndexesOf` to return ALL occurrences

func IndexesOf

func IndexesOf[K comparable](target K, array []K) []int

IndexesOf return every index where `target` exists in `array`

func RemoveCharsIn

func RemoveCharsIn(target string, cutset string) string

RemoveCharsIn removes any chars from `cutset` in `target`

func RemoveEmptyStrings

func RemoveEmptyStrings(targets []string) []string

Removes any empty strings found in `targets`

func RemoveRowsColumnsAtIndexes

func RemoveRowsColumnsAtIndexes[V CompatibleArrayTypes](rowIndexesToRemove, columnIndexesToRemove []int, inputArr [][]V) [][]V

RemoveRowColumnsAtIndexes, removes rows and/or columns, at their specified indexes from the 2D `inputArr`

func ReplaceCharactersMatchingCondition

func ReplaceCharactersMatchingCondition(target string, matchFunc func(r rune) bool, replaceWith string, mergeConsecutiveMatches bool) string

func TrimCharsAround

func TrimCharsAround(target string, cutset string, trimUntilNoChange bool) string

TrimCharsAround trims any chars found in `cutset` from `target`

if `trimUntilNoChange` is true, continues trimming until the string stops changing

func TrimWhitespaceAround

func TrimWhitespaceAround(target string, trimUntilNoChange bool) string

TrimWhitespaceAround trims any whitespace around `target`

if `trimUntilNoChange` is true, continues trimming until the string stops changing

func TrimWhitespaceAroundStrings

func TrimWhitespaceAroundStrings(targets []string) []string

Removes all whitespace around a list of strings

Types

type CompatibleArrayTypes

type CompatibleArrayTypes interface {
	string | interface{}
}

Jump to

Keyboard shortcuts

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