{"modulePath":"github.com/wavetermdev/waveterm/waveshell","version":"v0.7.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utilfn\n\n## Constants\n\n```go\nconst LineDiffVersion = 0\n```\n\n```go\nconst NoStrPos = -1\n```\nsentinel value for StrWithPos.Pos to indicate no position\n\n## Variables\n\n```go\nvar ErrOverflow = errors.New(\"integer overflow\")\n```\n\n```go\nvar HexDigits = []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}\n```\n\n## Functions\n\n```go\nfunc AddInt(left, right int) (int, error)\n```\nAdd two int values, returning an error if the result overflows.\n\n```go\nfunc AddIntSlice(vals ...int) (int, error)\n```\nAdd a slice of ints, returning an error if the result overflows.\n\n```go\nfunc AnsiGreenColor() string\n```\n\n```go\nfunc AnsiRedColor() string\n```\n\n```go\nfunc AnsiResetColor() string\n```\n\n```go\nfunc AppendNonZeroRandomBytes(b []byte, randLen int) []byte\n```\n\n```go\nfunc ApplyDiff(str1 string, diffBytes []byte) (string, error)\n```\n\n```go\nfunc ByteMapsEqual(m1 map[string][]byte, m2 map[string][]byte) bool\n```\n\n```go\nfunc ChunkSlice[T any](s []T, chunkSize int) [][]T\n```\n\n```go\nfunc CombineMaps[V any](m1 map[string]V, m2 map[string]V)\n```\nwill overwrite m1 with m2's values\n\n```go\nfunc CombineStrArrays(sarr1 []string, sarr2 []string) []string\n```\ncombines string arrays and removes duplicates (returns a new array)\n\n```go\nfunc ContainsStr(strs []string, test string) bool\n```\n\n```go\nfunc CopyToChannel(outputCh chan\u003c- []byte, reader io.Reader) error\n```\ndoes \\*not\\* close outputCh on EOF or error\n\n```go\nfunc CopyWithEndBytes(outputBuf *bytes.Buffer, reader io.Reader, endBytes []byte) (bool, error)\n```\nreturns (isEOF, error)\n\n```go\nfunc DecodeStringArray(barr []byte) ([]string, error)\n```\n\n```go\nfunc DecodeStringMap(barr []byte) (map[string]string, error)\n```\n\n```go\nfunc DetectMimeType(path string) string\n```\non error just returns \"\" does not return \"application/octet-stream\" as this is considered a detection failure\n\n```go\nfunc EllipsisStr(s string, maxLen int) string\n```\n\n```go\nfunc EncodeStringArray(arr []string) []byte\n```\n\n```go\nfunc EncodeStringMap(m map[string]string) []byte\n```\n\n```go\nfunc EncodedStringArrayGetFirstVal(encoded []byte) string\n```\non encoding error returns \"\" this is used to perform logic on first value without decoding the entire array\n\n```go\nfunc EncodedStringArrayHasFirstVal(encoded []byte, firstKey string) bool\n```\n\n```go\nfunc GetBool(v interface{}, field string) bool\n```\n\n```go\nfunc GetCmdExitCode(cmd *exec.Cmd, err error) int\n```\n\n```go\nfunc GetExitCode(err error) int\n```\n\n```go\nfunc GetFirstLine(s string) string\n```\n\n```go\nfunc GetMapKeys[K comparable, V any](m map[K]V) []K\n```\n\n```go\nfunc GetOrderedMapKeys[V any](m map[string]V) []string\n```\n\n```go\nfunc GetOrderedStringerMapKeys[K interface {\n\tcomparable\n\tfmt.Stringer\n}, V any](m map[K]V) []K\n```\n\n```go\nfunc GetStrArr(v interface{}, field string) []string\n```\n\n```go\nfunc IncSyncMap[K comparable, V int | int64](sm *SyncMap[K, V], key K, incAmt V)\n```\n\n```go\nfunc IsPrefix(strs []string, test string) bool\n```\n\n```go\nfunc LongestPrefix(root string, strs []string) string\n```\n\n```go\nfunc MakeDiff(str1 string, str2 string) []byte\n```\n\n```go\nfunc NullDecodeStr(barr []byte) (string, error)\n```\n\n```go\nfunc NullEncodeStr(s string) []byte\n```\nencodes a string, removing null/zero bytes (and separators '|') a zero byte is encoded as \"\\\\0\", a '\\\\' is encoded as \"\\\\\\\\\", sep is encoded as \"\\\\s\" allows for easy double splitting (first on \\\\x00, and next on \"|\")\n\n```go\nfunc QuickJson(v interface{}) string\n```\n\n```go\nfunc QuickParseJson[T any](s string) T\n```\n\n```go\nfunc Sha1Hash(data []byte) string\n```\nreturns base64 hash of data\n\n```go\nfunc ShellHexEscape(s string) string\n```\nreturns hex escaped string (\\\\xNN for each byte)\n\n```go\nfunc ShellQuote(val string, forceQuote bool, maxLen int) string\n```\nminimum maxlen=6\n\n```go\nfunc SortStringRunes(s string) string\n```\n\n```go\nfunc StrArrayToMap(sarr []string) map[string]bool\n```\n\n```go\nfunc StrMapsEqual(m1 map[string]string, m2 map[string]string) bool\n```\n\n```go\nfunc StrsEqual(s1arr []string, s2arr []string) bool\n```\n\n## Types\n\n```go\ntype LineDiffType struct {\n\tLines   []int\n\tNewData []string\n}\n```\n\n```go\ntype StrWithPos struct {\n\tStr string `json:\"str\"`\n\tPos int    `json:\"pos\"` // this is a 'rune' position (not a byte position)\n}\n```\n\n```go\nfunc ParseToSP(s string) StrWithPos\n```\n\n```go\nfunc (sp StrWithPos) Append(str string) StrWithPos\n```\n\n```go\nfunc (sp StrWithPos) Prepend(str string) StrWithPos\n```\n\n```go\nfunc (sp StrWithPos) String() string\n```\n\n```go\ntype SyncMap[K comparable, V any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc MakeSyncMap[K comparable, V any]() *SyncMap[K, V]\n```\n\n```go\nfunc (sm *SyncMap[K, V]) Clear()\n```\n\n```go\nfunc (sm *SyncMap[K, V]) Delete(k K)\n```\n\n```go\nfunc (sm *SyncMap[K, V]) Get(k K) V\n```\n\n```go\nfunc (sm *SyncMap[K, V]) GetEx(k K) (V, bool)\n```\n\n```go\nfunc (sm *SyncMap[K, V]) Keys() []K\n```\n\n```go\nfunc (sm *SyncMap[K, V]) Len() int\n```\n\n```go\nfunc (sm *SyncMap[K, V]) Replace(newMap map[K]V)\n```\n\n```go\nfunc (sm *SyncMap[K, V]) Set(k K, v V)\n```\n\n","path":"github.com/wavetermdev/waveterm/waveshell/pkg/utilfn","name":"utilfn","synopsis":"","isRedistributable":true}
