Documentation ¶
Index ¶
- Variables
- func AbsInt(n int) int
- func AbsInt64(n int64) int64
- func CielInt(a, b uint) int
- func CielInt64(a, b uint) int64
- func CielUint(a, b uint) uint
- func CielUint64(a, b uint) uint64
- func Printf(title string, value interface{})
- func Println(content string)
- func RandFloat64() float64
- func RandInt(min int, max int) int
- func RandString(len int) string
- func StrDeleteSpace(str string) string
- type Crontab
- func (c *Crontab) AddByFunc(id string, spec string, f func()) error
- func (c *Crontab) AddByID(id string, spec string, cmd cron.Job) error
- func (c *Crontab) DelByID(id string)
- func (c *Crontab) IDs() []string
- func (c *Crontab) IsExists(jid string) bool
- func (c *Crontab) Start()
- func (c *Crontab) Stop()
- type RandomAllocate
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RESpace = regexp.MustCompile(`\s+`) // Empty string RENumber = regexp.MustCompile(`([0-9\.]+)`) // Number REHex = regexp.MustCompile(`([a-fA-F0-9]+)`) // Hes RETimeRange = regexp.MustCompile(`\d{4}-\d{2}-\d{2}(\s*) - (\s*)\d{4}-\d{2}-\d{2}`) // Date range )
Functions ¶
func CielUint64 ¶
func RandFloat64 ¶
func RandFloat64() float64
func RandString ¶
func StrDeleteSpace ¶
Types ¶
type Crontab ¶
type Crontab struct {
// contains filtered or unexported fields
}
Crontab crontab manager
func NewCrontab ¶
NewCrontab new crontab secondsFieldLevel: 0 without,1 required,2 optional
type RandomAllocate ¶
type RandomAllocate struct { AmountTotal decimal.Decimal // Total amount MaxPercentOfOffset decimal.Decimal // Max percent of offset CountTotal uint // Allocate times ResultArrayAmount []decimal.Decimal // Allocated amount array ResultArrayPercent []decimal.Decimal // Allocated percent array // contains filtered or unexported fields }
Allocate total amount according to certain deviation
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 { fmt.Println(v.String()) totalAmount = totalAmount.Add(v) totalPercent = totalPercent.Add(p[i]) }
Click to show internal directories.
Click to hide internal directories.