misc

package module
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 17 Imported by: 37

README

Package misc implements a differents trivial functions

Documentation

Overview

Package misc implements a differents trivial functions

Index

Constants

View Source
const (
	// ExStopped --
	ExStopped int = iota + 200
	// 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 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 -- JSON format

View Source
const DateTimeFormatTZ = "-0700"

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 loggerFunc

Logger --

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 AddMessage

func AddMessage(msgs *[]string, msg string, params ...interface{})

AddMessage --

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 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 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 JoinedError

func JoinedError(msgs []string) error

JoinedError --

func LogProcessingTime

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

LogProcessingTime --

func MarshalBin

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

MarshalBin -- Don't forget call bufpool.PutBuf(buf) in the calling function!

func NormalizeSlashes

func NormalizeSlashes(u string) string

NormalizeSlashes --

func NowUTC

func NowUTC() time.Time

NowUTC --

func Sleep

func Sleep(duration time.Duration) bool

Sleep --

func StopApp

func StopApp(code int)

StopApp -- set exit code and raise application stop

func TrimStringAsFloat

func TrimStringAsFloat(s string) string

TrimStringAsFloat --

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) 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 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