Documentation
¶
Index ¶
- func ChunkSlice[T any](slice []T, chunkSize int) [][]T
- func CompareAsFloat64(a, b any) bool
- func ExpandHomeDir(pathStr string) (string, error)
- func ExpandHomeDirSafe(pathStr string) string
- func FromFloat64[T any](val float64) (T, bool)
- func GetHomeDir() string
- func GetTypedAtomValue[T any](rawVal any, atomName string) T
- func IsNumericType(val any) bool
- func JsonValEqual(a, b any) bool
- func MapToStruct(in map[string]any, out any) error
- func NumToString[T any](value T) (string, bool)
- func OpenBrowser(url string, delay time.Duration)
- func PanicHandler(debugStr string, recoverVal any) error
- func ReadLineWithTimeout(ch chan LineOutput, timeout time.Duration) (string, error)
- func StreamToLines(input io.Reader, lineFn func([]byte)) error
- func StreamToLinesChan(input io.Reader) chan LineOutput
- func StructToMap(in any) (map[string]any, error)
- func ToFloat64(val any) (float64, bool)
- func ToInt(val any) (int, bool)
- func ToInt64(val any) (int64, bool)
- func TruncateString(s string, maxLen int) string
- func ValidateAtomType(t reflect.Type, atomName string) error
- type JsonFieldInfo
- type LineOutput
- type LineWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChunkSlice ¶
func CompareAsFloat64 ¶
Helper to handle numeric comparisons as float64
func ExpandHomeDir ¶
func ExpandHomeDirSafe ¶
func FromFloat64 ¶
FromFloat64 converts a float64 to the specified numeric type T Returns the converted value and a bool indicating if the conversion was successful
func GetHomeDir ¶
func GetHomeDir() string
func GetTypedAtomValue ¶
func JsonValEqual ¶
this is a shallow equal, but with special handling for numeric types it will up convert to float64 and compare
func NumToString ¶
func OpenBrowser ¶
func PanicHandler ¶
PanicHandler handles panic recovery and logging. It can be called directly with recover() without checking for nil first. Example usage:
defer func() {
util.PanicHandler("operation name", recover())
}()
func ReadLineWithTimeout ¶ added in v0.12.3
func ReadLineWithTimeout(ch chan LineOutput, timeout time.Duration) (string, error)
func StreamToLines ¶ added in v0.12.3
func StreamToLinesChan ¶ added in v0.12.3
func StreamToLinesChan(input io.Reader) chan LineOutput
starts a goroutine to drive the channel line output does not include the trailing newline
func TruncateString ¶ added in v0.12.3
TruncateString truncates a string to maxLen runes (not bytes). If the string is longer than maxLen, it truncates to maxLen-3 and appends "...".
Types ¶
type JsonFieldInfo ¶
func ParseJSONTag ¶
func ParseJSONTag(field reflect.StructField) (JsonFieldInfo, bool)
type LineOutput ¶ added in v0.12.3
type LineWriter ¶ added in v0.12.3
type LineWriter struct {
// contains filtered or unexported fields
}
LineWriter is an io.Writer that processes data line-by-line via a callback. Lines do not include the trailing newline. Lines longer than maxLineLength are dropped.
func NewLineWriter ¶ added in v0.12.3
func NewLineWriter(lineFn func([]byte)) *LineWriter
NewLineWriter creates a new LineWriter with the given callback function.
func (*LineWriter) Flush ¶ added in v0.12.3
func (lw *LineWriter) Flush()
Flush outputs any remaining buffered data as a final line. Should be called when the input stream is complete (e.g., at EOF).