gtools

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

README

tools

useful tools for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func A2B added in v0.0.6

func A2B(v string) (bool, error)

func A2F added in v0.0.6

func A2F(v string) (float64, error)

func A2I added in v0.0.6

func A2I(v string) (int64, error)

func A2Ui added in v0.0.6

func A2Ui(v string) (uint64, error)

func B2a added in v0.0.5

func B2a(v bool) string

func Decode

func Decode(b []byte, e interface{}) error

Decode 将byte转为struct

func DecodeUnGzip

func DecodeUnGzip(b []byte, e interface{}) error

DecodeUnGzip 解压并将byte转为struct

func Encode

func Encode(e interface{}) ([]byte, error)

Encode 将struct转为byte

func EncodeGZip

func EncodeGZip(e interface{}) ([]byte, error)

EncodeGZip 将struct转为byte

func F2a added in v0.0.5

func F2a(v float64) string

func I2a added in v0.0.5

func I2a(v int64) string

func LocalhostIP

func LocalhostIP() (string, error)

本机ip

func NowInMillisecond

func NowInMillisecond() int64

NowInMillisecond return time now in Millisecond

func TypeName added in v0.0.3

func TypeName(t reflect.Type) string

TypeName get name of Type t

func Ui2a added in v0.0.5

func Ui2a(v uint64) string

uint to string base on 10

func Uint16ToByteArray

func Uint16ToByteArray(num uint16) []byte

Uint16ToByteArray 将uint16转为[]byte

func Uint32ToByteArray

func Uint32ToByteArray(num uint32) []byte

Uint32ToByteArray 将uint32转为[]byte

func Uint64ToByteArray

func Uint64ToByteArray(num uint64) []byte

Uint64ToByteArray 将uint64转为[]byte

Types

type IDGen

type IDGen struct {
	sync.Mutex
	// contains filtered or unexported fields
}

IDGen 自增id

func NewIDGen

func NewIDGen() *IDGen

NewIDGen 返回一个新的idGen

func (*IDGen) Next

func (id *IDGen) Next() uint64

Next 获取下一个id

Jump to

Keyboard shortcuts

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