Documentation
¶
Index ¶
- func Base58Encode(input []byte) string
- func Base58EncodeSHA256(input string) string
- func FormatDuration(d time.Duration) string
- func FormatTime(t time.Time) string
- func IsJSONArray(s string) bool
- func KebabToCamel(s string) string
- func MatchPattern(ctx context.Context, content string, patterns []string, opts ...MatchOption) bool
- func MatchPatternScanner(ctx context.Context, scanner *bufio.Scanner, patterns []string, ...) bool
- func ParseBool(_ context.Context, value any) (bool, error)
- func ParseTime(val string) (time.Time, error)
- func RandomString(n int) string
- func RemoveQuotes(s string) string
- func TruncString(val string, max int) string
- type KeyValue
- type MatchOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base58Encode ¶ added in v1.17.0
Base58Encode encodes a byte slice to base58 string. Uses the Bitcoin alphabet which excludes ambiguous characters (0, O, l, I).
func Base58EncodeSHA256 ¶ added in v1.17.0
Base58EncodeSHA256 generates a SHA-256 hash of the input and encodes it as base58. This is useful for creating deterministic, URL-safe identifiers.
func FormatDuration ¶ added in v1.18.0
FormatDuration formats a duration into a human-readable string. It handles negative durations by prepending a "-" sign. Examples:
- 500ms -> "500ms"
- 1.5s -> "1.5s"
- 2m30s -> "2m 30s"
- 1h30m -> "1h 30m"
- -500ms -> "-500ms"
- -2m30s -> "-2m 30s"
func IsJSONArray ¶ added in v1.17.0
IsJSONArray checks if the given string is a valid JSON array. This is useful for determining if parallel input should be parsed as JSON or space-separated.
func KebabToCamel ¶ added in v1.18.0
KebabToCamel converts a kebab-case string to camelCase.
func MatchPattern ¶
MatchPattern matches content against patterns using either literal or regex matching. For files or large content, use MatchPatternScanner instead.
func MatchPatternScanner ¶
func RandomString ¶ added in v1.18.0
RandomString generates a random string of length n using letters from letterBytes.
func RemoveQuotes ¶ added in v1.17.0
RemoveQuotes removes leading and trailing double quotes from a string if present, and unescapes the content using strconv.Unquote.
func TruncString ¶
TruncString returns truncated string.
Types ¶
type KeyValue ¶
type KeyValue string
func NewKeyValue ¶
func (KeyValue) MarshalJSON ¶
func (*KeyValue) UnmarshalJSON ¶
type MatchOption ¶
type MatchOption func(*matchOptions)
MatchOption represents an option for pattern matching
func WithExactMatch ¶
func WithExactMatch() MatchOption
WithExactMatch configures the matcher to use exact string matching for literal patterns
func WithMaxBufferSize ¶ added in v1.18.0
func WithMaxBufferSize(size int) MatchOption
WithMaxBufferSize configures the maximum buffer size for handling long lines