util

package
v0.0.0-...-7f422e9 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Array2Str

func Array2Str(array []int32) string

func AttachPanicHandle

func AttachPanicHandle(f func()) func()

func CheckGoroutineErr

func CheckGoroutineErr(errCtx context.Context) error

func GenerateSecret

func GenerateSecret() string

生成秘钥

func GenerateSha1Sign

func GenerateSha1Sign(params, appSecret string) string

func GenerateToken

func GenerateToken(username, password string) (string, error)

func Mkdir

func Mkdir(path string) error

创建单个文件路径

func MkdirAll

func MkdirAll(path string) error

创建多级路径

func PathExists

func PathExists(path string) (bool, error)

func RandInt

func RandInt(min, max int) int

func RemoveDuplicateElement

func RemoveDuplicateElement(src []string) []string

func SeparateTable

func SeparateTable(id string, count int) string

分表

func StartTicker

func StartTicker(d time.Duration, f func()) chan struct{}

注册定时器

func Str2Array

func Str2Array(s string) []int32

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string) (*Claims, error)

type GoTickets

type GoTickets interface {
	// 拿走一张票。
	Take()
	// 归还一张票。
	Return()
	// 票池是否已被激活。
	Active() bool
	// 票的总数。
	Total() uint32
	// 剩余的票数。
	Remainder() uint32
}

GoTickets 表示Goroutine票池的接口。

func NewGoTickets

func NewGoTickets(total uint32) (GoTickets, error)

NewGoTickets 会新建一个Goroutine票池。

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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