Common

package
v0.0.0-...-7f82f8f Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: MIT Imports: 26 Imported by: 10

Documentation

Index

Constants

View Source
const (
	LogLevelDrop = iota
	LogLevelDebug
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelNone
)

Variables

This section is empty.

Functions

func CheckPanic

func CheckPanic()

check panic when exit

func DeAES

func DeAES(in, key, iv []byte) ([]byte, error)

func DebugLog

func DebugLog(v ...interface{})

func DropLog

func DropLog(v ...interface{})

func EnAES

func EnAES(in, key, iv []byte) ([]byte, error)

key = "abcdefghijklmnopqrstuvwxyz123456" iv = "0123456789ABCDEF"

func ErrorLog

func ErrorLog(v ...interface{})

func FormatNow

func FormatNow() string

format time.Now() use FormatTime

func FormatTime

func FormatTime(t time.Time) string

format a time.Time to string as 2006-01-02 15:04:05.999

func FormatTime19

func FormatTime19(t time.Time) string

format a time.Time to string as 2006-01-02 15:04:05

func FormatUTC

func FormatUTC() string

format time.Now().UTC() use FormatTime

func Gunzip

func Gunzip(in []byte) ([]byte, error)

decompress data user gunzip

func Gzip

func Gzip(in []byte) ([]byte, error)

compress data use gzip

func Hash

func Hash(mem []byte) uint64

hash : []byte to uint64

func HupSignal

func HupSignal() <-chan os.Signal

reload signal

func InfoLog

func InfoLog(v ...interface{})

func Init

func Init(writer io.Writer)

parse flag and print usage/value to writer

func IsSystemdService

func IsSystemdService() bool

func ListenRpc

func ListenRpc(addr string, obj interface{}) error

func ListenSocket

func ListenSocket(addr string, keepalive bool, reactiver func(net.Conn)) error

func ListenUdp

func ListenUdp(addr string, bufsize int, reactiver func(*net.UDPAddr, []byte) []byte) error

func NewUUID

func NewUUID() string

create a uuid string

func NumberNow

func NumberNow() uint64

format time.Now() use NumberTime

func NumberTime

func NumberTime(t time.Time) uint64

format a time.Time to number as 20060102150405999

func NumberUTC

func NumberUTC() uint64

format time.Now().UTC() use NumberTime

func ParseNumber

func ParseNumber(t uint64) (time.Time, error)

func ParseNumberUTC

func ParseNumberUTC(t uint64) (time.Time, error)

func ParseTime

func ParseTime(s string) (time.Time, error)

parse a string to time.Time

func ParseTimeUTC

func ParseTimeUTC(s string) (time.Time, error)

parse a string as "2006-01-02 15:04:05.999" to time.Time

func QuitSignal

func QuitSignal() <-chan os.Signal

recive quit signal

func RunShell

func RunShell(exeStr string) (string, error)

func RuntimeInfo

func RuntimeInfo(w io.Writer)

func SetLogDir

func SetLogDir(dir string)

func SetLogLevel

func SetLogLevel(level int)

func SetLogTime

func SetLogTime(logtime bool)

func StringMapKeys

func StringMapKeys(m interface{}) (res []string)

func WarningLog

func WarningLog(v ...interface{})

Types

type EmptyStruct

type EmptyStruct struct{}

zero size, empty struct

type Lock

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

func NewLock

func NewLock() *Lock

func (*Lock) Lock

func (this *Lock) Lock()

func (*Lock) SchedLock

func (this *Lock) SchedLock()

func (*Lock) SpinLock

func (this *Lock) SpinLock(count int) bool

func (*Lock) TimeoutSchedLock

func (this *Lock) TimeoutSchedLock(t time.Duration) bool

func (*Lock) TimeoutSpinLock

func (this *Lock) TimeoutSpinLock(t time.Duration) bool

func (*Lock) TryLock

func (this *Lock) TryLock() bool

func (*Lock) Unlock

func (this *Lock) Unlock()

type Semaphore

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

func NewSemaphore

func NewSemaphore(capa int) *Semaphore

func (*Semaphore) Alloc

func (this *Semaphore) Alloc()

func (*Semaphore) Free

func (this *Semaphore) Free() bool

func (*Semaphore) TryAlloc

func (this *Semaphore) TryAlloc() bool

type StringList

type StringList []string

func (StringList) Count

func (this StringList) Count() int

func (StringList) Delete

func (this StringList) Delete(token string) int

func (StringList) IsEmpty

func (this StringList) IsEmpty() bool

func (StringList) Len

func (this StringList) Len() int

func (StringList) Less

func (this StringList) Less(i, j int) bool

func (StringList) Swap

func (this StringList) Swap(i, j int)

func (StringList) UniqueAdd

func (this StringList) UniqueAdd(token string) StringList

Jump to

Keyboard shortcuts

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