go_utils

package module
Version: v0.5.5 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CWD

func CWD() string

@title cwd @description 获取当前工作目录 @return string

func CielInt added in v0.3.2

func CielInt(a, b uint) int

func CielInt64 added in v0.3.2

func CielInt64(a, b uint) int64

func CielUint added in v0.3.2

func CielUint(a, b uint) uint

func CielUint64 added in v0.3.2

func CielUint64(a, b uint) uint64

func GetFuncName

func GetFuncName() string

获取正在运行的函数名

func GormErrorFilter added in v0.4.4

func GormErrorFilter(err error) error

func IsGormNotFound

func IsGormNotFound(err error) bool

func Printf

func Printf(title string, value interface{})

func Println

func Println(content string)

func QrCodeBase64

func QrCodeBase64(content string) string

func RandFloat64

func RandFloat64() float64

func RandInt

func RandInt(min int, max int) int

func RandString

func RandString(len int) string

func StrDeleteSpace added in v0.3.7

func StrDeleteSpace(str string) string

Types

type Crontab

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

Crontab crontab manager

func NewCrontab

func NewCrontab() *Crontab

NewCrontab new crontab

func (*Crontab) AddByFunc

func (c *Crontab) AddByFunc(id string, spec string, f func()) error

AddByFunc add function as crontab task

func (*Crontab) AddByID

func (c *Crontab) AddByID(id string, spec string, cmd cron.Job) error

AddByID add one crontab task id is unique spec is the crontab expression

func (*Crontab) DelByID

func (c *Crontab) DelByID(id string)

DelByID remove one crontab task

func (*Crontab) IDs

func (c *Crontab) IDs() []string

IDs ...

func (*Crontab) IsExists

func (c *Crontab) IsExists(jid string) bool

IsExists check the crontab task whether existed with job id

func (*Crontab) Start

func (c *Crontab) Start()

Start start the crontab engine

func (*Crontab) Stop

func (c *Crontab) Stop()

Stop stop the crontab engine

type Paging

type Paging struct {
	Page      uint   //current page number
	PageSize  uint   //list items number in per page
	TotalItem uint   //rows number in database
	TotalPage uint   //the count of all pages
	DBType    string //type of database,mysql or postgresql
}

func PagingGenerator added in v0.3.0

func PagingGenerator(page, pageSize, total uint, DBType string) (paging Paging, err error)

func (*Paging) GetQueryBegin

func (p *Paging) GetQueryBegin() (begin uint)

func (*Paging) GetQueryLimit added in v0.3.0

func (p *Paging) GetQueryLimit() (sql string)

func (*Paging) SetData

func (p *Paging) SetData() (begin uint, err error)

type RandomAllocate added in v0.4.1

type RandomAllocate struct {
	AmountTotal        decimal.Decimal   //总金额
	MaxOffsetPercent   decimal.Decimal   //最大偏差比例
	CountTotal         uint              //要分配的次数
	ResultArrayAmount  []decimal.Decimal //返回金额结果
	ResultArrayPercent []decimal.Decimal //返回比例结果
	// contains filtered or unexported fields
}

按一定偏差分配总金额 var m = randomAllocate{

AmountTotal:      decimal.NewFromFloat(1243.0),
CountTotal:       42,
MaxOffsetPercent: decimal.NewFromFloat(0.3),

} a, p := m.run()

totalAmount := decimal.NewFromInt(0) totalPercent := decimal.NewFromInt(0) for i, v := range a {

//GU.Printf("\n分配金额"+v.String(), "  比例"+p[i].String())
fmt.Println(v.String())
totalAmount = totalAmount.Add(v)
totalPercent = totalPercent.Add(p[i])

} GU.Printf("合计金额 ", totalAmount.String()) GU.Printf("合计比例 ", totalPercent.String())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL