tools

package module
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 37 Imported by: 1

README

tools

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FirstDayMonday bool
View Source
var TimeFormats = []string{"1/2/2006", "1/2/2006 15:4:5", "2006-1-2 15:4:5", "2006-1-2 15:4", "2006-1-2", "1-2", "15:4:5", "15:4", "15", "15:4:5 Jan 2, 2006 MST", "2006-01-02 15:04:05.999999999 -0700 MST"}

Functions

func BeginningOfDay

func BeginningOfDay() time.Time

func BeginningOfHour

func BeginningOfHour() time.Time

func BeginningOfMinute

func BeginningOfMinute() time.Time

func BeginningOfMonth

func BeginningOfMonth() time.Time

func BeginningOfQuarter

func BeginningOfQuarter() time.Time

func BeginningOfWeek

func BeginningOfWeek() time.Time

func BeginningOfYear

func BeginningOfYear() time.Time

func Between

func Between(time1, time2 string) bool

func CheckFileIsExist added in v1.1.0

func CheckFileIsExist(filename string) bool

* 检查文件是否存在

func CheckPriceFormat

func CheckPriceFormat(fee string) error

func ConvertFTOY

func ConvertFTOY(fen string) (yuan string, err error)

func ConvertYTOF

func ConvertYTOF(yuan string) (fen string, err error)

func CreateDir

func CreateDir(dirs ...string) error

@title createDir @description 批量创建文件夹 @auth (2020/04/05 20:22) @param dirs string @return err error

func EndOfDay

func EndOfDay() time.Time

func EndOfHour

func EndOfHour() time.Time

func EndOfMinute

func EndOfMinute() time.Time

func EndOfMonth

func EndOfMonth() time.Time

func EndOfQuarter

func EndOfQuarter() time.Time

func EndOfSunday

func EndOfSunday() time.Time

func EndOfWeek

func EndOfWeek() time.Time

func EndOfYear

func EndOfYear() time.Time

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func GenNo

func GenNo(prefix, suffix string) string

func GenUUID

func GenUUID() string

func GetLocalIp

func GetLocalIp() string

func GetNow

func GetNow() string

func JsonToMap

func JsonToMap(a interface{}) map[string]interface{}

* 把json 的struct 转换为 map

func MD4

func MD4(data string) string

func MD5

func MD5(data string) string

func MapToStr

func MapToStr(m map[string]interface{}) string

* map转换为 string. 对key=value的键值对用&连接起来,略过空值 并进行key值升序排列 去除string为空的值,保留 int为 0 的值

func Monday

func Monday() time.Time

func MustParse

func MustParse(strs ...string) time.Time

func Parse

func Parse(strs ...string) (time.Time, error)

func PathExists

func PathExists(path string) (bool, error)

func PostForm

func PostForm(url string, params url.Values) (data []byte, err error)

func PostJson

func PostJson(url string, jsonData []byte) (data []byte, err error)

func RandomString

func RandomString(num int) string

func Sha1WithRsa

func Sha1WithRsa(data, privateKey []byte) (sign string, err error)

func String

func String(v interface{}) string

func Sunday

func Sunday() time.Time

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

func Valid

func Valid(ptrInput interface{}) error

Types

type DownloadFile added in v1.0.9

type DownloadFile struct {
	File []byte
	Url  string
	Name string
}

func Download

func Download(url string) (file DownloadFile, err error)

type LQueue added in v1.2.3

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

建立一个任务

func NewQueue added in v1.2.3

func NewQueue(maxTaskCount int) *LQueue

创建一个新的任务队列 @maxTaskCount 最大执行数量

func (*LQueue) AddTask added in v1.2.3

func (q *LQueue) AddTask(task LTask)

增加一个任务

func (*LQueue) Close added in v1.2.3

func (q *LQueue) Close()

func (*LQueue) RunningState added in v1.2.3

func (q *LQueue) RunningState() (r LTaskRunning)

运行的状态

type LQueues added in v1.2.3

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

func NewQueues added in v1.2.3

func NewQueues() *LQueues

多任务按顺序执行

func (*LQueues) AddTask added in v1.2.3

func (q *LQueues) AddTask(key string, task LTask)

func (*LQueues) Close added in v1.2.3

func (q *LQueues) Close(key string)

func (*LQueues) CloseAll added in v1.2.3

func (q *LQueues) CloseAll()

func (*LQueues) Get added in v1.2.3

func (q *LQueues) Get(key string) (v interface{}, ok bool)

type LRunning added in v1.2.6

type LRunning int32

type LTask added in v1.2.3

type LTask interface {
	Run()
}

type LTaskDone added in v1.2.3

type LTaskDone interface {
	Done()
}

type LTaskPrepare added in v1.2.3

type LTaskPrepare interface {
	Prepare()
}

type LTaskRunning added in v1.2.3

type LTaskRunning struct {
	// 运行的起始时间
	StartTime int64
}

type Now

type Now struct {
	time.Time
}

func New

func New(t time.Time) *Now

func (*Now) BeginningOfDay

func (now *Now) BeginningOfDay() time.Time

func (*Now) BeginningOfHour

func (now *Now) BeginningOfHour() time.Time

func (*Now) BeginningOfMinute

func (now *Now) BeginningOfMinute() time.Time

func (*Now) BeginningOfMonth

func (now *Now) BeginningOfMonth() time.Time

func (*Now) BeginningOfQuarter

func (now *Now) BeginningOfQuarter() time.Time

func (*Now) BeginningOfWeek

func (now *Now) BeginningOfWeek() time.Time

func (*Now) BeginningOfYear

func (now *Now) BeginningOfYear() time.Time

func (*Now) Between

func (now *Now) Between(time1, time2 string) bool

func (*Now) EndOfDay

func (now *Now) EndOfDay() time.Time

func (*Now) EndOfHour

func (now *Now) EndOfHour() time.Time

func (*Now) EndOfMinute

func (now *Now) EndOfMinute() time.Time

func (*Now) EndOfMonth

func (now *Now) EndOfMonth() time.Time

func (*Now) EndOfQuarter

func (now *Now) EndOfQuarter() time.Time

func (*Now) EndOfSunday

func (now *Now) EndOfSunday() time.Time

func (*Now) EndOfWeek

func (now *Now) EndOfWeek() time.Time

func (*Now) EndOfYear

func (now *Now) EndOfYear() time.Time

func (*Now) Monday

func (now *Now) Monday() time.Time

func (*Now) MustParse

func (now *Now) MustParse(strs ...string) (t time.Time)

func (*Now) Parse

func (now *Now) Parse(strs ...string) (t time.Time, err error)

func (*Now) Sunday

func (now *Now) Sunday() time.Time

Jump to

Keyboard shortcuts

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