library

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Gray = uint8(iota + 90)
	Red
	Green
	Yellow
	Blue
	Magenta
	// NRed      = uint8(31) // Normal
	EndColor = "\033[0m"
)

Color number constants.

Variables

This section is empty.

Functions

func ColorLog

func ColorLog(format string, a ...interface{})

ColorLog prints colored log to stdout. See color rules in function 'ColorLogS'.

func ColorLogS

func ColorLogS(format string, a ...interface{}) string

ColorLogS colors log and return colored content. Log format: <level> <content [highlight][path]> [ error ]. Level: TRAC -> blue; ERRO -> red; WARN -> Magenta; SUCC -> green; others -> default. Content: default; path: yellow; error -> red. Level has to be surrounded by "[" and "]". Highlights have to be surrounded by "# " and " #"(space), "#" will be deleted. Paths have to be surrounded by "( " and " )"(space). Errors have to be surrounded by "[ " and " ]"(space). Note: it hasn't support windows yet, contribute is welcome.

func ExecCmd

func ExecCmd(cmdName string, args ...string) (string, string, error)

ExecCmd executes sys command and return stdout, stderr in string type, along with possible error.

func ExecCmdBytes

func ExecCmdBytes(cmdName string, args ...string) ([]byte, []byte, error)

ExecCmdBytes executes sys command and return stdout, stderr in bytes type, along with possible error.

func ExecCmdDir

func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error)

ExecCmdDir executes sys command in given directory and return stdout, stderr in string type, along with possible error.

func ExecCmdDirBytes

func ExecCmdDirBytes(dir, cmdName string, args ...string) ([]byte, []byte, error)

ExecCmdDirBytes executes sys command in given directory and return stdout, stderr in bytes type, along with possible error.

func FileExists

func FileExists(name string) bool

FileExists reports whether the named file or directory exists.

func FindTreeIds

func FindTreeIds(root *Tree) []int

遍历树所有的id

func GetTreeByDepList

func GetTreeByDepList(rootid int, datas []Dep, root *Tree)

填充树 递归数组

func InArray

func InArray(val string, arr []string) (exist bool, index int)

InArray 判断是否在数组中

func InIntArray

func InIntArray(v int, sl []int) bool

InIntArray 判断是否在int数组中

func InUint64Array

func InUint64Array(v uint64, sl []uint64) bool

InUint64Array 判断是否在int数组中

func IsChineseChar

func IsChineseChar(str string) bool

IsChineseChar 判断字符串是否包含中文字符

func IsDir

func IsDir(dir string) bool

IsDir 判断是否为目录

func IsEmail

func IsEmail(b []byte) bool

IsEmail 判断是否为邮箱格式

func IsFile

func IsFile(filePath string) bool

IsFile 判断是否为文件

func NewPool

func NewPool(n, bufSize int) *pool

NewPool ...

func Nl2br

func Nl2br(s string) string

Nl2br 换行符换成<br />

func Now

func Now() int

Now 当前时间戳

func String2Timestamp

func String2Timestamp(str string) int64

String2Timestamp 时间格式化为时间戳

func Substr

func Substr(s string, start, length int) string

Substr returns the substr from start to length.

func Timestamp2String

func Timestamp2String(timestamp int) string

Timestamp2String 时间格式化

func VerCompare

func VerCompare(ver1, ver2 string) int

VerCompare 版本对比 v1比v2大返回1,小于返回-1,等于返回0

Types

type Dep

type Dep struct {
	RootID  int         `json:"root_id"`
	ChildID int         `json:"child_id"`
	Value   interface{} `json:"value"`
}

只需指定两个id的父子关系,即可得到一颗树形结构

type Tree

type Tree struct {
	ID       int         `json:"id"`
	Value    interface{} `json:"value"`
	Children []*Tree     `json:"children"`
}

Tree ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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