stringutil

package
v1.16.4 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: GPL-2.0, GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTime

func FormatTime(t time.Time) string

FormatTime returns formatted time.

func MatchPattern

func MatchPattern(ctx context.Context, content string, patterns []string, opts ...MatchOption) bool

MatchPattern matches content against patterns using either literal or regex matching. For files or large content, use MatchPatternScanner instead.

func MatchPatternScanner

func MatchPatternScanner(ctx context.Context, scanner *bufio.Scanner, patterns []string, opts ...MatchOption) bool

func ParseTime

func ParseTime(val string) (time.Time, error)

ParseTime parses time string.

func TruncString

func TruncString(val string, max int) string

TruncString TurnString returns truncated string.

Types

type KeyValue

type KeyValue string

func NewKeyValue

func NewKeyValue(key, value string) KeyValue

func (KeyValue) Bool

func (kv KeyValue) Bool() bool

func (KeyValue) Key

func (kv KeyValue) Key() string

func (KeyValue) MarshalJSON

func (kv KeyValue) MarshalJSON() ([]byte, error)

func (KeyValue) String

func (kv KeyValue) String() string

func (*KeyValue) UnmarshalJSON

func (kv *KeyValue) UnmarshalJSON(data []byte) error

func (KeyValue) Value

func (kv KeyValue) Value() string

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

Jump to

Keyboard shortcuts

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