util

package
v0.0.0-...-f23cdb6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var TPLFuncMap = template.FuncMap{
	"sum": sum,
}

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 DockerTagVersion

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

func FileExists

func FileExists(name string) (bool, error)

func Find

func Find[T any](s []T, f func(T) bool) (T, 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(needle string, haystack []string) bool

func IsJSON

func IsJSON(str string) bool

func IsUUID

func IsUUID(str string) bool

func IsValidURL

func IsValidURL(addr string) bool

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.

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