utils

package
v0.0.0-...-06c59fd Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Fatal = iota
	Error
	Warning
	Info
	Debug
	Trace
)

Variables

View Source
var (
	ErrEris     = &errEris{}
	ErrEmperror = &errEmperror{}
	ErrErrorx   = &errErrorx{}
)
View Source
var Empty = &api.Empty{}
View Source
var Level = Info

Functions

func AssertErr

func AssertErr(err error)

func AssertErrf

func AssertErrf(err error, format string, args ...any)

func Assertf

func Assertf(condition bool, format string, args ...any)

func Doc

func Doc(text string) string

func DocFmt

func DocFmt(text string, args ...any) string

func Docf

func Docf(format string, args ...any) string

func ErrFull

func ErrFull(err error) string

func Errf

func Errf(format string, args ...any) error

func Filter

func Filter[T any](slice []T, fn func(T) bool) []T

func FirstNonZero

func FirstNonZero[T comparable](values ...T) T

func Group

func Group[T any, Q comparable](slice []T, fn func(T) Q) [][]T

func HomeDir

func HomeDir() string

func If

func If[T any](cond bool, then, else_ T) T

func IgnoreErr

func IgnoreErr(_ error)

func Indent

func Indent(text string, indent string)

func IsTerminal

func IsTerminal(file *os.File) bool

func Logf

func Logf(ctx context.Context, level int, format string, args ...any)

func Map

func Map[T any, Q any](slice []T, f func(T) Q) []Q

remove if not used

func Panicf

func Panicf(format string, args ...any)

func Prepend

func Prepend[T any](slice []T, elems ...T) []T

func TerminalWidth

func TerminalWidth(file *os.File) int

func WrapExtendf

func WrapExtendf(err error, format string, args ...any) error

func Wrapf

func Wrapf(err error, format string, args ...any) error

Types

type Logger

type Logger interface {
	Logf(level int, format string, args ...any)
	Fatalf(format string, args ...any)
	Errorf(format string, args ...any)
	Warningf(format string, args ...any)
	Infof(format string, args ...any)
	Debugf(format string, args ...any)
	Tracef(format string, args ...any)
}

func NewLogger

func NewLogger(out *os.File, prefix string, showTimestamp bool) Logger

type Slice

type Slice[T any] struct {
	Values []T
}

func (*Slice[T]) Append

func (slice *Slice[T]) Append(newValues ...T) *Slice[T]

func (*Slice[T]) AppendIf

func (slice *Slice[T]) AppendIf(condition bool, newValues ...T) *Slice[T]

Jump to

Keyboard shortcuts

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