mutils

package
v0.0.0-...-3c81578 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToInt

func BytesToInt(b []byte) int

字节转换成整形

func CheckOrCreateDir

func CheckOrCreateDir(dir string) (string, error)

CheckOrCreateDir 检查或生成路径

func CreateFile

func CreateFile(fname string) (*os.File, error)

CreateFile 创建文件

func DeJSON

func DeJSON(data []byte, v interface{}) error

DeJSON decode json to interface

func DeepCopy

func DeepCopy(src, dest interface{}) error

DeepCopy 深复制

func EnJSON

func EnJSON(v interface{}) ([]byte, error)

EnJSON 解析成json

func EnJSONStr

func EnJSONStr(v interface{}) (string, error)

EnJSONStr 解析成json str

func GenerateSelfSignedCertificate

func GenerateSelfSignedCertificate(keyFile, certFile, domain string) error

生成自定义的签名证书

func Index

func Index(s interface{}, slice interface{}) int

Index 下标 TODO bug

func IndexA

func IndexA(a []interface{}, fn func(i int) bool) int

IndexA 获取字符串在数组的下标,如果重复只返回第一个

func IndexS

func IndexS(slice interface{}, fn func(i int) bool) int

IndexS 获取字符串在数组的下标,如果重复只返回第一个

func IndexStringArray

func IndexStringArray(s string, a []string) int

IndexStringArray 字符串在数组下标

func Int10Ints

func Int10Ints(num int) []int

func IntTInts

func IntTInts(num int, base uint8) []int

func IntToByte

func IntToByte(n int) []byte

整形转换成字节

func IntfaceToInt64

func IntfaceToInt64(x interface{}) (int64, error)

IntfaceToInt64 将interface转换为int64

func IntfaceToString

func IntfaceToString(x interface{}) (string, error)

IntfaceToString 将interface转换为string

func Ints10Int

func Ints10Int(mods []int) int

func IntsTInt

func IntsTInt(mods []int, base uint8) int

func IntsToString

func IntsToString(arr []int) string

func JSONConvert

func JSONConvert(m interface{}, dest interface{}) (err error)

func LoadCertificate

func LoadCertificate(keyFile, certFile, domain string) (tls.Certificate, error)

LoadCertificate loads a certificate given a private key and certificate PEM files. Only in case the associated domain is localhost and no files are specified a self signed certificate will be automatically generated.

func RandomString

func RandomString(n int) string

RandomString 随机字符串

func RemoveDuplicatesInts

func RemoveDuplicatesInts(nums []int) []int

func ReversBytes

func ReversBytes(bs []byte)

func ReversInts

func ReversInts(bs []int)

func ReverseString

func ReverseString(s string) string

func SnakeName

func SnakeName(base string) string

SnakeName 驼峰转蛇形

func TransFieldName

func TransFieldName(name string) string

TransFieldName 转换字段名称 测试性能不够

Types

type InterfaceHeap

type InterfaceHeap []interface{}

InterfaceHeap 任意堆,用于在具体实现时进行继承

func (InterfaceHeap) Len

func (h InterfaceHeap) Len() int

实现sort.Interface Less方法需要被继承重写

func (InterfaceHeap) Less

func (h InterfaceHeap) Less(i, j int) bool

func (*InterfaceHeap) Pop

func (h *InterfaceHeap) Pop() interface{}

Pop heap.Interface

func (*InterfaceHeap) Push

func (h *InterfaceHeap) Push(x interface{})

Push heap.Interface

func (InterfaceHeap) Swap

func (h InterfaceHeap) Swap(i, j int)

type Item

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

An Item is something we manage in a priority queue.

type JsonConvert

type JsonConvert struct{}

func (*JsonConvert) Convert

func (j *JsonConvert) Convert(src, dest interface{}) error

type ModelConvertor

type ModelConvertor interface {
	Convert(src, dest interface{}) error
}

模型转换器

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

Pop implements

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

Push implements

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

Jump to

Keyboard shortcuts

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