Documentation
¶
Index ¶
- Constants
- Variables
- func AddElemToSliceUniq[T comparable](arr []T, elem T) []T
- func BoundValue(val, minVal, maxVal int) int
- func CalculateDeltas(values []float64) []float64
- func CleanTag(tag string) string
- func CleanTagSlice(tags []string) []string
- func CompareSemVerCore(ver1, ver2 string) (int, error)
- func ConvertMap(val any) map[string]any
- func ConvertToWallClockPT(t time.Time) time.Time
- func CopyFile(src, dst string) error
- func CopyStrArr(arr []string) []string
- func DrainChan[T any](ch chan T)
- func ExpandHomeDir(pathStr string) string
- func GetHomeDir() string
- func GetJsonTag(field reflect.StructField) string
- func GetKeys[K comparable, V any](m map[K]V) []K
- func GetOrderedMapKeys[V any](m map[string]V) []string
- func InDockerEnv() bool
- func IndentString(indent string, str string) string
- func IsASCIISpace(b byte) bool
- func IsSemVerCore(ver string) bool
- func LaunchUrl(url string) error
- func MoveSliceIdxToFront[T any](arr []T, idx int) []T
- func NeedsLock(rval reflect.Value) bool
- func NormalizeName(name string) string
- func ParseTags(input string) []string
- func ReUnmarshal(out any, in any) error
- func RemoveElemFromSlice[T comparable](arr []T, elem T) []T
- func SafeSubstring(s string, start, end int) string
- func SliceIdx[T comparable](arr []T, elem T) int
- func StarMatchString(pattern string, s string, delimiter string) bool
- func StripPreReleaseInfo(ver string) string
- func TeeCopy(src io.Reader, dst io.Writer, dataCallbackFn func([]byte)) error
- func TryLockWithTimeout(locker sync.Locker, timeout time.Duration) (func(), time.Duration)
- func WriteFileIfDifferent(fileName string, contents []byte) (bool, error)
- type LineBuf
Constants ¶
const MaxLineLength = 64 * 1024
const MaxNameLen = 60
const MaxTagLen = 40
const SimpleTagRegexStr = `[a-zA-Z0-9][a-zA-Z0-9/_.:-]*`
Variables ¶
var NameRegex = regexp.MustCompile(`^[a-zA-Z0-9_.#\[\]/-]+$`)
var PTLoc *time.Location
var TagRegex = regexp.MustCompile(`(?:^|\s)(#` + SimpleTagRegexStr + `)`)
must have whitespace or EOL on either side
Functions ¶
func AddElemToSliceUniq ¶
func AddElemToSliceUniq[T comparable](arr []T, elem T) []T
func BoundValue ¶
func CalculateDeltas ¶
CalculateDeltas converts a slice of values to deltas between consecutive values The first value is kept as is, and subsequent values are the difference from the previous value If a value is exactly 0, it's treated as a counter reset and outputs 0 (not a negative delta)
func CleanTagSlice ¶ added in v0.7.4
func CompareSemVerCore ¶ added in v0.4.4
CompareSemVerCore compares two semver strings and returns -1, 0, or 1 based on just the *core* versions It ignores pre-release and build metadata Works with "v" prefixed or unprefixed versions
func ConvertMap ¶ added in v0.2.0
func CopyStrArr ¶
func ExpandHomeDir ¶
func GetHomeDir ¶
func GetHomeDir() string
func GetJsonTag ¶
func GetJsonTag(field reflect.StructField) string
func GetKeys ¶ added in v0.9.0
func GetKeys[K comparable, V any](m map[K]V) []K
func GetOrderedMapKeys ¶
func InDockerEnv ¶ added in v0.8.0
func InDockerEnv() bool
func IndentString ¶
func IsASCIISpace ¶ added in v0.8.3
func IsSemVerCore ¶ added in v0.4.4
IsSemVerCore validates that the whole string *is exactly* a core semver
func LaunchUrl ¶ added in v0.7.0
MakeLaunchUrlCommand creates a command to open a URL in the default browser for the current operating system
func MoveSliceIdxToFront ¶
func NormalizeName ¶ added in v0.9.0
func ReUnmarshal ¶
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 SafeSubstring ¶ added in v0.4.3
SafeSubstring safely extracts a substring from the original string based on position
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 StripPreReleaseInfo ¶ added in v0.4.4
StripPreReleaseInfo extracts just the version core (major.minor.patch) from a semver string Preserves the "v" prefix if present in the original version
func TryLockWithTimeout ¶
Types ¶
type LineBuf ¶
type LineBuf struct {
// contains filtered or unexported fields
}
func MakeLineBuf ¶
func MakeLineBuf() *LineBuf
func (*LineBuf) GetPartialAndReset ¶
func (*LineBuf) ProcessBuf ¶
processes the buffer, returns lines (partial lines are retained)