Documentation ¶
Overview ¶
Package misc implements a differents trivial functions
Package misc implements a differents trivial functions
Index ¶
- Constants
- Variables
- func AbsPath(name string) (string, error)
- func AbsPathEx(name string, base string) (string, error)
- func AddExitFunc(name string, f ExitFunc, param any)
- func AppExecName() string
- func AppExecPath() string
- func AppFullName() string
- func AppName() string
- func AppStartTime() time.Time
- func AppStarted() bool
- func AppTags() string
- func AppVersion() string
- func AppWorkDir() string
- func BaseType(srcT reflect.Type) (t reflect.Type)
- func BuildTime() string
- func BuildTimeTS() time.Time
- func CheckTimePrecision(precision string, upToSecond bool) bool
- func Copyright() string
- func DelExitFunc(name string)
- func Duration2Interval(d time.Duration) string
- func Exit()
- func ExitCode() int
- func GetFuncName(shift int, shortName bool) string
- func GetMyIPs() (map[string]bool, error)
- func GzipPack(data io.Reader) (b *bytes.Buffer, err error)
- func GzipRepack(data io.Reader) (b *bytes.Buffer, err error)
- func GzipUnpack(data io.Reader) (b *bytes.Buffer, err error)
- func Iface2Bool(x any) (v bool, err error)
- func Iface2Float(x any) (v float64, err error)
- func Iface2IfacePtr(src any, dstPtr any) (err error)
- func Iface2Int(x any) (v int64, err error)
- func Iface2String(x any) (v string, err error)
- func Iface2Time(x any) (v time.Time, err error)
- func Iface2Uint(x any) (v uint64, err error)
- func Int2Interval(d int64) string
- func Interval2Duration(interval string) (time.Duration, error)
- func Interval2Int64(interval string) (int64, error)
- func IsDebug() bool
- func IsMyIP(ip string) (bool, error)
- func JoinByteSlices(prefix []byte, suffix []byte, sep []byte, in [][]byte) (out []byte)
- func JoinStrings(prefix string, suffix string, sep string, in []string) (out string)
- func LoadEnv(fileName string) (e error)
- func LogProcessingTime(facility string, level string, id uint64, module string, message string, ...) int64
- func MarshalBin(src any) (buf *bytes.Buffer, err error)
- func NormalizeSlashes(u string) string
- func NowUTC() time.Time
- func NowUnix() int64
- func NowUnixNano() int64
- func ParseJSONtime(s string) (t time.Time, err error)
- func SetExitTimeouts(newTerminationTimeout time.Duration, newKillingTimeout time.Duration) (prevTerminationTimeout time.Duration, prevKillingTimeout time.Duration)
- func Sha512Hash(p []byte) []byte
- func Sleep(duration time.Duration) bool
- func StopApp(code int)
- func StructFieldName(f *reflect.StructField, tp string) (name string)
- func StructFieldTags(s any, fields []string, tp string) (names []string, err error)
- func Time2JSON(t time.Time) string
- func Time2JSONtz(t time.Time) string
- func Time2JSONutc(t time.Time) string
- func TimePrecisionDivider(precision string, upToSecond bool) (int64, error)
- func TrimStringAsFloat(s string) string
- func UnixNano2JSON(ts int64) string
- func UnixNano2UTC(ts int64) time.Time
- func UnmarshalBin(buf *bytes.Buffer, dst any) (err error)
- func UnsafeByteSlice2String(b []byte) (s string)
- func UnsafeString2ByteSlice(s string) (b []byte)
- func WaitingForStop()
- func WaitingForStopChan() <-chan time.Time
- type BoolMap
- type ByteSliceMap
- type CallStackFrame
- type CtxInt64
- type CtxKey
- type CtxString
- type CtxUint64
- type Error
- type ExitFunc
- type Float64Map
- type Int64Map
- type IntMap
- type InterfaceMap
- func (m InterfaceMap) GetBool(name string) (v bool, err error)
- func (m InterfaceMap) GetFloat(name string) (v float64, err error)
- func (m InterfaceMap) GetInt(name string) (v int64, err error)
- func (m InterfaceMap) GetString(name string) (v string, err error)
- func (m InterfaceMap) GetTime(name string) (v time.Time, err error)
- func (m InterfaceMap) GetUint(name string) (v uint64, err error)
- type Messages
- type Replace
- type StringMap
- type Uint64Map
- type UintMap
Constants ¶
const ( // ExPanic -- ExPanic = 70 // ExStopped -- ExStopped = 1 // ExVersion -- ExVersion = 64 // ExMissingConfigFile -- ExMissingConfigFile = 66 // ExIncorrectConfigFile -- ExIncorrectConfigFile = 78 // ExConfigIncorrect -- ExConfigIncorrect = 78 // ExConfigErrors -- ExConfigErrors = 78 // ExCreateListenerError -- ExCreateListenerError = 71 // ExStartListenerError -- ExStartListenerError = 71 // ExServiceInitializationError -- ExServiceInitializationError = 71 // ExServiceError -- ExServiceError = 71 // ExAccessDenied -- ExAccessDenied = 77 // ExProgrammerError -- ExProgrammerError = 70 )
Appliction exit codes
const DateFormat string = "02-01-2006"
DateFormat -- standard format of the date
const DateFormatRev string = "2006-01-02"
DateFormatRev -- reversed format of the date
const DateTimeFormat string = DateFormat + " " + TimeFormat
DateTimeFormat -- format of the date and time
const DateTimeFormatJSON string = DateTimeFormatJSONWithoutZ + "Z"
const DateTimeFormatJSONTZ string = DateFormatRev + "T" + TimeFormatWithMS + DateTimeFormatTZ
DateTimeFormatJSONTZ -- JSON format with TZ
const DateTimeFormatJSONWithoutZ string = DateFormatRev + "T" + TimeFormatWithMS
DateTimeFormatJSON -- JSON format
const DateTimeFormatRev string = DateFormatRev + " " + TimeFormat
DateTimeFormatRev -- standard format of the date and time with reversed date
const DateTimeFormatRevWithMS string = DateFormatRev + " " + TimeFormatWithMS
DateTimeFormatRevWithMS -- standard format of the date and time with reversed date and milliseconds
const DateTimeFormatShortJSON string = DateFormatRev + "T" + TimeFormat
DateTimeFormatShortJSON -- Short JSON format
const DateTimeFormatShortJSONTZ string = DateFormatRev + "T" + TimeFormat + DateTimeFormatTZ
DateTimeFormatShortJSONTZ -- Short JSON format with TZ
const DateTimeFormatTZ = "Z07:00"
DateTimeFormatTZ --
const DateTimeFormatWithMS string = DateFormat + " " + TimeFormatWithMS
DateTimeFormatWithMS -- standard format of the date and time with milliseconds
const (
DefaultEnvFile = ".env"
)
const EOS string = "\n"
EOS -- EndOfString
const TimeFormat string = "15:04:05"
TimeFormat -- format of the time
const TimeFormatWithMS string = "15:04:05.000"
TimeFormatWithMS -- format of the time with milliseconds
Variables ¶
var (
// Logger --
Logger loggerFunc
)
var ( // TEST -- test mode TEST = false )
Functions ¶
func AppExecPath ¶
func AppExecPath() string
AppExecPath -- full path of the application executable file
func AppName ¶
func AppName() string
AppName -- name of the application executable file without last extension
func CheckTimePrecision ¶ added in v0.1.38
CheckTimePrecision --
func Duration2Interval ¶ added in v1.1.4
func GetFuncName ¶
GetFuncName -- name of the function from call stack
func GzipRepack ¶ added in v0.1.18
GzipRepack -- data will be truncated by ReadFrom!
func GzipUnpack ¶ added in v0.1.18
GzipUnpack -- data will be truncated by ReadFrom!
func Iface2IfacePtr ¶ added in v0.1.51
func Int2Interval ¶ added in v1.1.4
func Interval2Duration ¶ added in v0.1.38
Interval2Duration --
func Interval2Int64 ¶ added in v0.1.38
Interval2Int64 --
func JoinByteSlices ¶ added in v0.1.45
func JoinStrings ¶ added in v0.1.45
func LogProcessingTime ¶
func LogProcessingTime(facility string, level string, id uint64, module string, message string, t0 int64) int64
LogProcessingTime --
func ParseJSONtime ¶ added in v0.1.25
ParseJSONtime --
func SetExitTimeouts ¶ added in v0.1.50
func StructFieldName ¶ added in v0.1.64
func StructFieldName(f *reflect.StructField, tp string) (name string)
func StructFieldTags ¶ added in v1.1.3
func TimePrecisionDivider ¶ added in v0.1.38
TimePrecisionDivider --
func UnsafeByteSlice2String ¶ added in v0.1.42
UnsafeByteSlice2String -- fast convert []byte to string without memory allocs Don't forget to use runtime.KeepAlive(b) in the caller if necessary!
func UnsafeString2ByteSlice ¶ added in v0.1.42
UnsafeString2ByteSlice -- fast convert string to []byte without memory allocs Don't forget to use runtime.KeepAlive(s) in the caller if necessary! Don't try to change result without thinking hard before that!
func WaitingForStopChan ¶ added in v0.1.55
WaitingForStopChan --
Types ¶
type CallStackFrame ¶
CallStackFrame -- call stack element
type InterfaceMap ¶
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 --
type Messages ¶ added in v0.1.21
type Messages struct {
// contains filtered or unexported fields
}
Messages --
type Replace ¶ added in v0.1.8
type Replace []replaceDef
Replace --
type StringMap ¶
StringMap --
func StructFieldOpts ¶ added in v0.1.66
func StructFieldOpts(f *reflect.StructField, tp string) (opts StringMap)