hutils

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 15 Imported by: 0

README

hutils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefTimeUtil = NewTimeUtil()
)

Functions

func AppendBytes added in v0.0.2

func AppendBytes(fpath string, bs []byte) error

func EncodePassword added in v0.1.6

func EncodePassword(password, salt string) string

func FormatTime added in v0.1.3

func FormatTime(t time.Time) string

func InitRandSeed added in v0.1.7

func InitRandSeed()

func MD5 added in v0.1.5

func MD5(s string) string

func Must

func Must(i interface{}, e error) interface{}

func NewDataSourceName added in v0.0.2

func NewDataSourceName(user, password, host, port, dbName string) string

func Now added in v0.1.3

func Now() time.Time

func RandString added in v0.1.5

func RandString(n int) string

func ReadFile

func ReadFile(fpath string) ([]byte, error)

func ReadJson

func ReadJson(fpath string, i interface{}) error

func ReadToml

func ReadToml(fpath string, i interface{}) error

func Recover added in v0.1.1

func Recover()

func Wait added in v0.1.7

func Wait(timeout, step time.Duration, f func() bool) bool

func WriteBytes added in v0.0.2

func WriteBytes(fpath string, data []byte) error

func WriteJson added in v0.0.2

func WriteJson(fpath string, i interface{}) error

Types

type BufferPool added in v0.1.2

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

func NewBufferPool added in v0.1.2

func NewBufferPool() *BufferPool

func (*BufferPool) Get added in v0.1.2

func (b *BufferPool) Get() *hbuffer.Buffer

func (*BufferPool) Put added in v0.1.2

func (b *BufferPool) Put(buf *hbuffer.Buffer)

type TimeUtil added in v0.1.3

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

时间工具,在测试中,很多时候需要控制 time.Now() 产生的时间 例如:设置当前时间为 3天 后,用正常时间的 1/10 行进时间

func NewTimeUtil added in v0.1.3

func NewTimeUtil() *TimeUtil

func (*TimeUtil) Add added in v0.1.3

func (t *TimeUtil) Add(duration time.Duration)

func (*TimeUtil) Now added in v0.1.3

func (t *TimeUtil) Now() time.Time

func (*TimeUtil) SetDebug added in v0.1.3

func (t *TimeUtil) SetDebug(isDebug bool)

func (*TimeUtil) SetNow added in v0.1.3

func (t *TimeUtil) SetNow(now time.Time)

Jump to

Keyboard shortcuts

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