util

package module
v0.0.0-...-ab1236c Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: MIT Imports: 11 Imported by: 0

README

Go - Util V1

The code will be gradually improved.

Documentation

Overview

Package util ... 本队列工具取自:https://github.com/yireyun/go-queue,有少许修改。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExist

func FileExist(path string) (bool, error)

FileExist will check file or dir exist.

func NewLine

func NewLine() string

func PowerOff

func PowerOff(force, reboot bool)

func RandInt

func RandInt(min int, max int) int

RandInt 随机整数

func RandomHex

func RandomHex(l int) string

RandomHex 随机十六进制字符串

func SequenceEqual

func SequenceEqual(a []byte, b []byte) bool

SequenceEqual will check 2 arrays sequence equal.

func SubStr

func SubStr(s string, pos, length int) string

SubStr will split string using index and length

func Substr

func Substr(s string, pos int) string

Substr will split string using index

func UintptrToString

func UintptrToString(ptr uintptr) string

UintptrToString uinptr转GoString

Types

type LogLevel

type LogLevel int

LogLevel is log level.

const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
	FATAL
)

LogLevel enums.

type Logger

type Logger struct {
	Type  string //
	Src   string
	Level LogLevel //Log level
}

Logger is a common console and file logger.

func NewLogger

func NewLogger(typpe, src string, lv LogLevel) *Logger

NewLogger will return Logger strcut instance.

func (*Logger) LogDebug

func (lgr *Logger) LogDebug(tag, msg interface{})

LogDebug will record debug infomation.

func (*Logger) LogError

func (lgr *Logger) LogError(tag, msg interface{})

LogError will record error.

func (*Logger) LogFatal

func (lgr *Logger) LogFatal(tag, msg interface{})

LogFatal will record fatal.

func (*Logger) LogInfo

func (lgr *Logger) LogInfo(tag, msg interface{})

LogInfo will record infomation.

func (*Logger) LogWarn

func (lgr *Logger) LogWarn(tag, msg interface{})

LogWarn will record warning.

type Queue

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

Queue EsQueue是一个无锁队列。原作者yireyun(https://github.com/yireyun),有少许修改。

func NewQueue

func NewQueue(capaciity uint32) *Queue

NewQueue 新建队列

func (*Queue) Capaciity

func (q *Queue) Capaciity() uint32

Capaciity 获取当前最大容量

func (*Queue) Dequeue

func (q *Queue) Dequeue(val *interface{}) bool

Dequeue 单个元素出队

func (*Queue) Enqueue

func (q *Queue) Enqueue(val interface{})

Enqueue 单个元素入队

func (*Queue) GetCount

func (q *Queue) GetCount() uint32

GetCount 获取当前队列元素数量

func (*Queue) String

func (q *Queue) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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