utils

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePath

func CreatePath(dir string) error

CreatePath 创建目录,可创建多级目录

func DateDiff added in v0.2.1

func DateDiff(before int64, after int64) int

DateDiff 求两个时间相隔几天

func ExePath

func ExePath() string

ExePath 返回当前执行文件所在的路径

func FuncName

func FuncName() string

func GetAge

func GetAge(idCardNo string) int

GetAge 根据身份证号码获取用户年龄

func GetFirstDateOfWeek added in v0.2.2

func GetFirstDateOfWeek(now time.Time) time.Time

一个星期的第一天

func IsFileOrDirectoryExist

func IsFileOrDirectoryExist(path string) bool

IsFileOrDirectoryExist 判断文件或者目录是否存在

func MakeSureDBExist

func MakeSureDBExist(username, passwd, host string, port int, dbname string) error

MakeSureDBExist 确认一个Mysql数据库存在

func ProjectPath

func ProjectPath() string

ProjectPath 返回当前的go程序的工程路径 也就是其所属的 gopath

func RemoveDuplicatesAndEmpty

func RemoveDuplicatesAndEmpty(slc []string) []string

RemoveDuplicatesAndEmpty 剔除空数组和重复的数组

func RemoveEmpty

func RemoveEmpty(a []string) (ret []string)

RemoveEmpty 剔除空数组

func Reverse

func Reverse(s []byte) []byte

Reverse 将s反序

func WriteUint16ToBuffer

func WriteUint16ToBuffer(b *bytes.Buffer, v uint16)

WriteUint16ToBuffer 向bytes.Buffer中以小端序写入一个uint16

func WriteUint32ToBuffer

func WriteUint32ToBuffer(b *bytes.Buffer, v uint32)

WriteUint32ToBuffer 向bytes.Buffer中以小端序写入一个uint32

func WriteUint64ToBuffer

func WriteUint64ToBuffer(b *bytes.Buffer, v uint64)

WriteUint64ToBuffer 向bytes.Buffer中以小端序写入一个uint64

Types

type RotateLog

type RotateLog struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

RotateLog 可自动按天切换的日志

func NewRotateLog

func NewRotateLog(filename string) *RotateLog

NewRotateLog 获取一个滚动日志写入器

func (*RotateLog) Filename

func (r *RotateLog) Filename() string

Filename 日志文件名

func (*RotateLog) LastDate

func (r *RotateLog) LastDate() time.Time

LastDate 最后的日志日期

func (*RotateLog) Logger

func (r *RotateLog) Logger() (*log.Logger, error)

Logger 获取当前的日志,如果滚动失败则返回错误

Jump to

Keyboard shortcuts

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