goutil

package module
v0.0.0-...-59f51cb Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: LGPL-3.0 Imports: 9 Imported by: 1

README

Build Status Code Climate

Some useful functions for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffSlices

func DiffSlices[K comparable](one []K, two []K) (oldS []K, newS []K)

DiffSlices returns differense between two slices

func JoinInt

func JoinInt(array []int, sep string) string

JoinInt concatenates integers in one string with defined separator

func MemberOfSlice

func MemberOfSlice[K comparable](element K, slice []K) bool

MemberOfSlice checks if object is element of slice

func NewConfig

func NewConfig(file string, c IConfig, vers []int) error

NewConfig for parsing and validating YAML config

func StrCat

func StrCat(args ...string) string

StrCat concatenates string arguments in one string

func StrCatS

func StrCatS(args []string) string

StrCatS concatenates slice of strings in one string

func StrCatSln

func StrCatSln(args []string) string

StrCatSln concatenates slice of strings in one string with newline

func StrCatln

func StrCatln(args ...string) string

StrCatln concatenates string arguments in one string with newline

Types

type IConfig

type IConfig interface {
	IConfigVer
	Check() error
}

IConfig interface for checking version and general config validation

func NewMultiConfig

func NewMultiConfig(file string, cfgver IConfigVer, cfgmap func(int) IConfig) (IConfig, error)

NewMultiConfig for parsing and validating YAML config and map to config-dependent structs

type IConfigVer

type IConfigVer interface {
	GetVer() int
}

IConfigVer interface for checking version

type Logger

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

Logger struct

func NewLogger

func NewLogger(l Loglevel, s *syslog.Writer) *Logger

NewLogger creates new Logger object

func (*Logger) Debug

func (l *Logger) Debug(f string, s ...interface{})

Debug wraps log.Printf with loglevel check

func (*Logger) Error

func (l *Logger) Error(f string, s ...interface{})

Error wraps log.Printf with loglevel check

func (*Logger) Fatal

func (l *Logger) Fatal(f string, s ...interface{})

Fatal wraps log.Fatalf with loglevel check

func (*Logger) Info

func (l *Logger) Info(f string, s ...interface{})

Info wraps log.Printf with loglevel check

func (*Logger) Warn

func (l *Logger) Warn(f string, s ...interface{})

Warn wraps log.Printf with loglevel check

type Loglevel

type Loglevel int

Loglevel typedef for integer

const (
	NONE Loglevel = iota
	FATAL
	ERROR
	WARN
	INFO
	DEBUG
)

Enum with logging levels

func ParseLoglevel

func ParseLoglevel(level string) Loglevel

ParseLoglevel function converts string representation of log levels to int

Jump to

Keyboard shortcuts

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