misc

package module
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 21 Imported by: 37

README

Package misc implements a differents trivial functions

Documentation

Overview

Package misc implements a differents trivial functions

Package misc implements a differents trivial functions

Index

Constants

View Source
const (
	// ExPanic --
	ExPanic int = iota + 200
	// ExStopped --
	ExStopped
	// ExVersion --
	ExVersion
	// ExMissingConfigFile --
	ExMissingConfigFile
	// ExIncorrectConfigFile --
	ExIncorrectConfigFile
	// ExConfigIncorrect --
	ExConfigIncorrect
	// ExConfigErrors --
	ExConfigErrors
	// ExCreateListenerError --
	ExCreateListenerError
	// ExStartListenerError --
	ExStartListenerError
	// ExServiceInitializationError --
	ExServiceInitializationError
	// ExServiceError --
	ExServiceError
	// ExAccessDenied --
	ExAccessDenied
	// ExProgrammerError --
	ExProgrammerError
)

Appliction exit codes

View Source
const DateFormat string = "02-01-2006"

DateFormat -- standard format of the date

View Source
const DateFormatRev string = "2006-01-02"

DateFormatRev -- reversed format of the date

View Source
const DateTimeFormat string = DateFormat + " " + TimeFormat

DateTimeFormat -- format of the date and time

View Source
const DateTimeFormatJSON string = DateFormatRev + "T" + TimeFormatWithMS + "Z"

DateTimeFormatJSON -- JSON format

View Source
const DateTimeFormatJSONTZ string = DateFormatRev + "T" + TimeFormatWithMS + DateTimeFormatTZ

DateTimeFormatJSONTZ -- JSON format with TZ

View Source
const DateTimeFormatRev string = DateFormatRev + " " + TimeFormat

DateTimeFormatRev -- standard format of the date and time with reversed date

View Source
const DateTimeFormatRevWithMS string = DateFormatRev + " " + TimeFormatWithMS

DateTimeFormatRevWithMS -- standard format of the date and time with reversed date and milliseconds

View Source
const DateTimeFormatShortJSON string = DateFormatRev + "T" + TimeFormat

DateTimeFormatShortJSON -- Short JSON format

View Source
const DateTimeFormatShortJSONTZ string = DateFormatRev + "T" + TimeFormat + DateTimeFormatTZ

DateTimeFormatShortJSONTZ -- Short JSON format with TZ

View Source
const DateTimeFormatTZ = "Z07:00"

DateTimeFormatTZ --

View Source
const DateTimeFormatWithMS string = DateFormat + " " + TimeFormatWithMS

DateTimeFormatWithMS -- standard format of the date and time with milliseconds

View Source
const EOS string = "\n"

EOS -- EndOfString

View Source
const TimeFormat string = "15:04:05"

TimeFormat -- format of the time

View Source
const TimeFormatWithMS string = "15:04:05.000"

TimeFormatWithMS -- format of the time with milliseconds

Variables

View Source
var (

	// Logger --
	Logger loggerFunc
)
View Source
var (
	// TEST -- test mode
	TEST = false
)

Functions

func AbsPath

func AbsPath(name string) (string, error)

AbsPath --

func AbsPathEx added in v0.1.4

func AbsPathEx(name string, base string) (string, error)

AbsPathEx --

func AddExitFunc

func AddExitFunc(name string, f ExitFunc, param interface{})

AddExitFunc --

func AppExecName

func AppExecName() string

AppExecName -- name of the application executable file

func AppExecPath

func AppExecPath() string

AppExecPath -- full path of the application executable file

func AppFullName

func AppFullName() string

AppFullName -- application name with full path

func AppName

func AppName() string

AppName -- name of the application executable file without last extension

func AppStartTime

func AppStartTime() time.Time

AppStartTime -- time of the apptication start

func AppStarted

func AppStarted() bool

AppStarted -- is application started?

func AppTags added in v0.1.14

func AppTags() string

AppTags -- application tags

func AppVersion

func AppVersion() string

AppVersion -- application version

func AppWorkDir

func AppWorkDir() string

AppWorkDir -- directory where application started from

func BuildTime

func BuildTime() string

BuildTime --

func BuildTimeTS

func BuildTimeTS() time.Time

BuildTimeTS --

func Copyright() string

Copyright --

func DelExitFunc

func DelExitFunc(name string)

DelExitFunc --

func Exit

func Exit()

Exit -- exit application

func ExitCode

func ExitCode() int

ExitCode -- get current exit code

func GetFuncName

func GetFuncName(shift int, shortName bool) string

GetFuncName -- name of the function from call stack

func GetMyIPs

func GetMyIPs() (map[string]bool, error)

GetMyIPs --

func GzipPack added in v0.1.18

func GzipPack(data io.Reader) (b *bytes.Buffer, err error)

GzipPack -- data will be truncated by ReadFrom!

func GzipRepack added in v0.1.18

func GzipRepack(data io.Reader) (b *bytes.Buffer, err error)

GzipRepack -- data will be truncated by ReadFrom!

func GzipUnpack added in v0.1.18

func GzipUnpack(data io.Reader) (b *bytes.Buffer, err error)

GzipUnpack -- data will be truncated by ReadFrom!

func Iface2Bool added in v0.1.33

func Iface2Bool(x interface{}) (v bool, err error)

Iface2Bool --

func Iface2Float

func Iface2Float(x interface{}) (v float64, err error)

Iface2Float --

func Iface2Int

func Iface2Int(x interface{}) (v int64, err error)

Iface2Int --

func Iface2String

func Iface2String(x interface{}) (v string, err error)

Iface2String --

func Iface2Uint

func Iface2Uint(x interface{}) (v uint64, err error)

Iface2Uint --

func IsDebug

func IsDebug() bool

IsDebug --

func IsMyIP

func IsMyIP(ip string) (bool, error)

IsMyIP --

func LoadEnv added in v0.1.24

func LoadEnv(fileName string) (e error)

LoadEnv --

func LogProcessingTime

func LogProcessingTime(facility string, level string, id uint64, module string, message string, t0 int64) int64

LogProcessingTime --

func MarshalBin

func MarshalBin(src interface{}) (buf *bytes.Buffer, err error)

MarshalBin --

func NormalizeSlashes

func NormalizeSlashes(u string) string

NormalizeSlashes --

func NowUTC

func NowUTC() time.Time

NowUTC --

func NowUnix added in v0.1.23

func NowUnix() int64

NowUnix --

func NowUnixNano added in v0.1.23

func NowUnixNano() int64

NowUnixNano --

func ParseJSONtime added in v0.1.25

func ParseJSONtime(s string) (t time.Time, err error)

ParseJSONtime --

func Sha512Hash added in v0.1.34

func Sha512Hash(p []byte) []byte

Sha512Hash --

func Sleep

func Sleep(duration time.Duration) bool

Sleep --

func StopApp

func StopApp(code int)

StopApp -- set exit code and raise application stop

func Time2JSON added in v0.1.27

func Time2JSON(t time.Time) string

Time2JSON --

func TrimStringAsFloat

func TrimStringAsFloat(s string) string

TrimStringAsFloat --

func UnixNano2JSON added in v0.1.27

func UnixNano2JSON(ts int64) string

UnixNano2JSON --

func UnixNano2UTC added in v0.1.26

func UnixNano2UTC(ts int64) time.Time

UnixNano2UTC --

func UnmarshalBin

func UnmarshalBin(buf *bytes.Buffer, dst interface{}) (err error)

UnmarshalBin --

func WaitingForStop

func WaitingForStop()

WaitingForStop --

Types

type BoolMap added in v0.1.9

type BoolMap map[string]bool

BoolMap --

type ByteSliceMap added in v0.1.11

type ByteSliceMap map[string][]byte

ByteSliceMap --

type CallStackFrame

type CallStackFrame struct {
	FuncName string
	FileName string
	Line     int
}

CallStackFrame -- call stack element

func GetCallStack

func GetCallStack(shift int) []CallStackFrame

GetCallStack -- get call stack

type CtxInt64 added in v0.1.5

type CtxInt64 int64

CtxInt64 --

type CtxString added in v0.1.5

type CtxString string

CtxString --

type CtxUint64 added in v0.1.5

type CtxUint64 uint64

CtxUint64 --

type Error

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

Error --

func MakeError

func MakeError(code int, format string, options ...interface{}) *Error

MakeError --

func (*Error) Code

func (me *Error) Code() int

Code --

func (*Error) Error

func (me *Error) Error() string

Error --

func (*Error) SetCode

func (me *Error) SetCode(code int)

SetCode --

func (*Error) SetMessage

func (me *Error) SetMessage(format string, options ...interface{})

SetMessage --

type ExitFunc

type ExitFunc func(code int, param interface{})

ExitFunc --

type Float64Map added in v0.1.9

type Float64Map map[string]float64

Float64Map --

type Int64Map added in v0.1.9

type Int64Map map[string]int64

Int64Map --

type IntMap added in v0.1.9

type IntMap map[string]int

IntMap --

type InterfaceMap

type InterfaceMap map[string]interface{}

InterfaceMap --

func (InterfaceMap) GetBool added in v0.1.33

func (m InterfaceMap) GetBool(name string) (v bool, err error)

GetBool --

func (InterfaceMap) GetFloat

func (m InterfaceMap) GetFloat(name string) (v float64, err error)

GetFloat --

func (InterfaceMap) GetInt

func (m InterfaceMap) GetInt(name string) (v int64, err error)

GetInt --

func (InterfaceMap) GetString

func (m InterfaceMap) GetString(name string) (v string, err error)

GetString --

func (InterfaceMap) GetUint

func (m InterfaceMap) GetUint(name string) (v uint64, err error)

GetUint --

type Messages added in v0.1.21

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

Messages --

func NewMessages added in v0.1.32

func NewMessages() *Messages

NewMessages --

func (*Messages) Add added in v0.1.21

func (m *Messages) Add(msg string, params ...interface{})

Add --

func (*Messages) AddError added in v0.1.21

func (m *Messages) AddError(err error)

AddError --

func (*Messages) Error added in v0.1.21

func (m *Messages) Error(separators ...string) error

Error --

func (*Messages) Len added in v0.1.30

func (m *Messages) Len() int

Len --

func (*Messages) String added in v0.1.21

func (m *Messages) String(separators ...string) string

String --

type Replace added in v0.1.8

type Replace []replaceDef

Replace --

func NewReplace added in v0.1.8

func NewReplace() *Replace

NewReplace --

func (*Replace) Add added in v0.1.8

func (r *Replace) Add(re string, replaceTo string) error

Add --

func (*Replace) AddMulti added in v0.1.8

func (r *Replace) AddMulti(list map[string]string) error

AddMulti --

func (*Replace) Do added in v0.1.8

func (r *Replace) Do(s string) string

Do --

type StringMap

type StringMap map[string]string

StringMap --

type Uint64Map added in v0.1.9

type Uint64Map map[string]uint64

Uint64Map --

type UintMap added in v0.1.9

type UintMap map[string]uint

UintMap --

Jump to

Keyboard shortcuts

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