utilcommon

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(err error)

func CatchPanic

func CatchPanic(aCallBackFunc func(args ...interface{}), args ...interface{})

捕获panic转为log输出, 建议加入有可能panic的函数中,用defer方式调用 aCallBackFunc 为回调函数, 如果调用方需要处理panic后事宜, 需要传入,不需要则传nil args为回调函数参数

func FileExist

func FileExist(filename string) bool

检查文件或目录是否存在 如果由 filename 指定的文件或目录存在则返回 true,否则返回 false

func FileRead

func FileRead(path string) ([]byte, error)

func FileReadByLine

func FileReadByLine(path string, deal func(line []byte) error) error

ReadFileOneLine 逐行读取文件 通过deal处理

func FileWrite

func FileWrite(path string, data []byte) error

func InternalIp

func InternalIp() string

服务器IP地址

func JoinPaths

func JoinPaths(absolutePath, relativePath string) string

func Pid

func Pid() int

func ProcessName

func ProcessName() string

func VersionCompare

func VersionCompare(v1, v2 string) int

VersionCompare for compare v1 and v2. =0, <-1, >1, 非法-2

Types

type Random

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

func NewRandom

func NewRandom() *Random

func (*Random) GetRandInt

func (p *Random) GetRandInt(min, max int) int

生成[min, max]之间的随机数

func (*Random) IsTrue

func (p *Random) IsTrue(val interface{}) (truth bool)

Jump to

Keyboard shortcuts

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