util

package
v0.0.0-...-e61e790 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinWidth = 0
	TabWidth = 0
	PadChar  = ' '
)

Variables

View Source
var ErrMalformedURL error = errors.New("malformed url")
View Source
var ErrNotAURL error = errors.New("not a url")
View Source
var TPLFuncMap = template.FuncMap{
	"sum": sum,
	"now": now,
}

Functions

func AddSocketLogHook

func AddSocketLogHook(path string) error

func AppendIfMissing

func AppendIfMissing[V comparable](slice []V, i V) []V

func ApplianceVersionString

func ApplianceVersionString(v *version.Version) string

func BaseAuthContext

func BaseAuthContext(token string) context.Context

func DockerTagVersion

func DockerTagVersion(v *version.Version) (string, error)

func FileExists

func FileExists(name string) (bool, error)

func Filter

func Filter[A any](s []A, f func(A) bool) []A

func Find

func Find[A any](s []A, f func(A) bool) (A, error)

func Getenv

func Getenv(key, fallback string) string

Getenv returns environment variable value, if it does not exist, return fallback

func InSlice

func InSlice[C comparable](n C, h []C) bool

func InSliceFunc

func InSliceFunc[A any](n A, h []A, f func(i, p A) bool) bool

func IsJSON

func IsJSON(str string) bool

func IsUUID

func IsUUID(str string) bool

func IsValidURL

func IsValidURL(addr string) error

IsValidURL tests a string to determine if it is a well-structured url or not.

func NewPrinter

func NewPrinter(output io.Writer, padding int) *tabby.Tabby

func NormalizeURL

func NormalizeURL(u string) (*url.URL, error)

func ParseFilteringFlags

func ParseFilteringFlags(flags *pflag.FlagSet, defaultFilter map[string]map[string]string) (map[string]map[string]string, []string, bool)

func PrefixStringLines

func PrefixStringLines(s, prefixChar string, prefixLength int) string

func PrintJSON

func PrintJSON(output io.Writer, v interface{}) error

func Reverse

func Reverse[S ~[]T, T any](items S) S

func SearchSlice

func SearchSlice(needle string, haystack []string, caseInsensitive bool) []string

SearchSlice will search a slice of strings and return all matching results. The search can either be case sensitive or not.

func SlicePop

func SlicePop[T any](s []T, i int) ([]T, T)

func SliceTake

func SliceTake[T any](s []T, amount int) (picked, remaining []T)

func SmallestGroupIndex

func SmallestGroupIndex[T any](groups [][]T) int

func StringAbbreviate

func StringAbbreviate(s string) string

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

func NewHook

func NewHook(protocol, address string, levels []logrus.Level, formatter logrus.Formatter) (*Hook, error)

func (*Hook) Fire

func (h *Hook) Fire(entry *logrus.Entry) error

func (*Hook) Levels

func (h *Hook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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