common

package module
v0.0.0-...-537e507 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ellipsis

func Ellipsis(s string, maxLength int, breakOnSpace bool) string

Ellipsis truncates string to be at most maxLength runes long maxLength = resultStringLength + len("...")

func FromJson

func FromJson[T any](data []byte) (*T, error)

FromJson just tries to convert json string to object

func FromJsonFile

func FromJsonFile[T any](path string) (*T, error)

FromJsonFile decodes json file into an object

func GetConfig

func GetConfig[T any](args []string, configPathFlag string) (*T, error)

GetConfig loads configuration defined by type T. Initial configuration is loaded from file defined by the "config" flag, File values could be overridden by the command line flags.

func IfEmpty

func IfEmpty(a string, b string) string

func IfNull

func IfNull[T any](a *T, b *T) *T

func OrExit

func OrExit[T any](v T, e error) T

func Set

func Set[T any](target *T) func(T)

Set creates a function that updates target to given value.

func UUID4

func UUID4() string

func UUID4For

func UUID4For(i interface{}) string

UUID4For converts interface to json bytes, hashes it and uses result to generate an UUID4 string.

Types

type Logger

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

func NewLogger

func NewLogger(name string) *Logger

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...any)

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...any)

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...any)

Jump to

Keyboard shortcuts

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