utils

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: MIT Imports: 19 Imported by: 0

README

go-utils

Documentation

Index

Constants

View Source
const (
	GOTIMEFORMAT = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func Bytes2Str

func Bytes2Str(b []byte) string

func BytesToFloat32

func BytesToFloat32(bytes []byte) float32

BytesToFloat32 bytes转float32

func BytesToFloat64

func BytesToFloat64(bytes []byte) float64

BytesToFloat64 bytes转float64

func BytesToInt8s

func BytesToInt8s(i []byte) []int8

BytesToInt8s byte数组转int8数组

func BytesToUint64

func BytesToUint64(buf []byte) uint64

BytesToUint64 byte数组转uint64

func CamelString

func CamelString(s string) string

CamelString 蛇形转驼峰

func CrashLog added in v0.2.0

func CrashLog() string

CrashLog 捕获panic 打印堆栈信息

func DecodeBig5

func DecodeBig5(s []byte) ([]byte, error)

convert BIG5 to UTF-8

func DecodeGBK

func DecodeGBK(s []byte) ([]byte, error)

convert GBK to UTF-8

func DumpStacks

func DumpStacks(stackSize int) string

DumpStacks dump堆栈信息

func EncodeBig5

func EncodeBig5(s []byte) ([]byte, error)

convert UTF-8 to BIG5

func EncodeGBK

func EncodeGBK(s []byte) ([]byte, error)

convert UTF-8 to GBK

func Float32ToBytes

func Float32ToBytes(float float32) []byte

Float32ToBytes float32转bytes

func Float64ToBytes

func Float64ToBytes(float float64) []byte

Float64ToBytes float64转bytes

func GetHash64

func GetHash64(input []byte) (uint64, error)

GetHash64 得到64bit hash值

func GetYAML

func GetYAML(f string, s interface{}) error

GetYAML 从yaml配置文件解析到struct

func Int8sToBytes

func Int8sToBytes(i []int8) []byte

Int8sToBytes int8数组转byte数组

func SetupSigusr1Trap

func SetupSigusr1Trap()

SetupSigusr1Trap 捕获到指定signal时打印出goroutine堆栈

func SliceSize

func SliceSize(a interface{}) int

SliceSize interface装的slice时 获取slice的长度

func SnakeString

func SnakeString(s string) string

SnakeString 驼峰转蛇形

func Str2Bytes

func Str2Bytes(s string) []byte

func StrToTime

func StrToTime(t string) time.Time

StrToTime string => time.Time

func StringToUint64

func StringToUint64(a string) uint64

StringToUint64 string转uint64

func TimeToStr

func TimeToStr(t time.Time) string

TimeToStr time.Time => string

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Uint64ToBytes unit64转byte数组

func Uint64ToString

func Uint64ToString(a uint64) string

Uint64ToString uint64转string

Types

type YAMLDate

type YAMLDate struct {
	Time time.Time
}

YAMLDate 能从yaml解析出Date

func (YAMLDate) MarshalYAML

func (t YAMLDate) MarshalYAML() (interface{}, error)

MarshalYAML 实现接口

func (*YAMLDate) Set

func (t *YAMLDate) Set(tm time.Time)

Set 设置

func (YAMLDate) ToString

func (t YAMLDate) ToString() string

ToString 返回字符串

func (*YAMLDate) UnmarshalYAML

func (t *YAMLDate) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML 实现接口

Jump to

Keyboard shortcuts

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