Documentation
¶
Index ¶
- Variables
- func AddElemToSliceUniq[T comparable](arr []T, elem T) []T
- func AtomicRenameCopy(dstPath string, srcPath string, perms os.FileMode) error
- func CompareAsFloat64(a, b any) bool
- func ContainsStr(strs []string, test string) bool
- func ConvertToWallClockPT(t time.Time) time.Time
- func DoMapStructure(out any, input any) error
- func DrainChannelSafe[T any](ch <-chan T, debugName string)
- func DumpGoRoutineStacks(w io.Writer)
- func FindStringInSlice(slice []string, val string) int
- func FormatLsTime(t time.Time) string
- func GetJsonTag(field reflect.StructField) string
- func GetLineColFromOffset(barr []byte, offset int) (int, int)
- func GetMapKeys[K comparable, V any](m map[K]V) []K
- func GetOrderedMapKeys[V any](m map[string]V) []string
- func GracefulClose(closer io.Closer, debugName, closerName string) bool
- func HasBinaryData(data []byte) bool
- func IndentString(indent string, str string) string
- func IsNumericType(val any) bool
- func JsonValEqual(a, b any) bool
- func MapToStruct(in map[string]any, out any) error
- func MoveSliceIdxToFront[T any](arr []T, idx int) []T
- func Ptr[T any](x T) *T
- func QuickHashString(s string) string
- func RandomHexString(numHexDigits int) (string, error)
- func ReUnmarshal(out any, in any) error
- func ReadLineWithTimeout(ch chan LineOutput, timeout time.Duration) (string, error)
- func RemoveElemFromSlice[T comparable](arr []T, elem T) []T
- func SafeDeref[T any](x *T) T
- func ShellQuote(val string, forceQuote bool, maxLen int) string
- func SliceIdx[T comparable](arr []T, elem T) int
- func StarMatchString(pattern string, s string, delimiter string) bool
- func StrSetIntersection(s1 []string, s2 []string) []string
- func StreamToLines(input io.Reader, lineFn func([]byte), readCallback func()) error
- func StreamToLinesChan(input io.Reader) chan LineOutput
- func StructToMap(in any) (map[string]any, error)
- func TimeoutFromContext(ctx context.Context, defaultTimeout time.Duration) time.Duration
- func ToFloat64(val any) (float64, bool)
- func ToInt(val any) (int, bool)
- func ToInt64(val any) (int64, bool)
- func WriteFileIfDifferent(fileName string, contents []byte) (bool, error)
- func WriteTemplateToFile(fileName string, templateText string, vars map[string]string) error
- type LineOutput
Constants ¶
This section is empty.
Variables ¶
var PTLoc *time.Location
Functions ¶
func AddElemToSliceUniq ¶
func AddElemToSliceUniq[T comparable](arr []T, elem T) []T
func AtomicRenameCopy ¶
func CompareAsFloat64 ¶
Helper to handle numeric comparisons as float64
func ContainsStr ¶
func DoMapStructure ¶
does a mapstructure using "json" tags
func DrainChannelSafe ¶
DrainChannelSafe will drain a channel until it is empty or until a timeout is reached.
func DumpGoRoutineStacks ¶
func FindStringInSlice ¶
func FormatLsTime ¶
func GetJsonTag ¶
func GetJsonTag(field reflect.StructField) string
func GetMapKeys ¶
func GetMapKeys[K comparable, V any](m map[K]V) []K
func GetOrderedMapKeys ¶
func HasBinaryData ¶
func IndentString ¶
func JsonValEqual ¶
this is a shallow equal, but with special handling for numeric types it will up convert to float64 and compare
func MoveSliceIdxToFront ¶
func Ptr ¶
func Ptr[T any](x T) *T
*
- Utility function for referencing a type with a pointer.
- This is the same as dereferencing with &, but unlike &
- you can directly use it on the ouput of a function
- without needing to create an intermediate variable
func QuickHashString ¶
func RandomHexString ¶
every byte is 4-bits of randomness
func ReUnmarshal ¶
func ReadLineWithTimeout ¶
func ReadLineWithTimeout(ch chan LineOutput, timeout time.Duration) (string, error)
func RemoveElemFromSlice ¶
func RemoveElemFromSlice[T comparable](arr []T, elem T) []T
removes an element from a slice and modifies the original slice (the backing elements) if it removes the last element from the slice, it will return nil so we free the original slice's backing memory
func SafeDeref ¶
func SafeDeref[T any](x *T) T
*
- Helper function that will deref a pointer if not null
- but returns a default value if it is null.
func ShellQuote ¶
minimum maxlen=6, pass -1 for no max length
func SliceIdx ¶
func SliceIdx[T comparable](arr []T, elem T) int
func StarMatchString ¶
matches a delimited string with a pattern string the pattern string can contain "*" to match a single part, or "**" to match the rest of the string note that "**" may only appear at the end of the string
func StrSetIntersection ¶
func StreamToLines ¶
func StreamToLinesChan ¶
func StreamToLinesChan(input io.Reader) chan LineOutput
starts a goroutine to drive the channel line output does not include the trailing newline