Documentation ¶
Index ¶
- func ByteToFloat32(bs []byte) float32
- func ByteToFloat64(bs []byte) float64
- func BytetoInt(bs []byte) int
- func ConvertToString(src string, srcCode string, tagCode string) string
- func DecryptAES128(data, key []byte) ([]byte, error)
- func EncryptAES128(data, key, iv []byte) ([]byte, error)
- func ExtractStr(str string, substr string) string
- func Float32ToByte(f32 float32) []byte
- func Float64ToByte(f64 float64) []byte
- func GetAllfiles(dirPath string, files []string) ([]string, error)
- func GetCurrentDir() (string, error)
- func GetCurrentPath() (string, error)
- func GetDirFiles(dir string) (files []string, err error)
- func GetFileLineCount(file io.Reader) (count int, err error)
- func GetFileSize(filePath string) (fileSize int64, err error)
- func GetRandomInt(start, end int) int
- func GetRandomName() string
- func GetRandomString(n int) string
- func GetValidFileName(name string, extName string) string
- func GetZoneTime(zoneName string, timeStr string) (lt time.Time, err error)
- func IntToByte(n int) []byte
- func IsFileExist(filePath string) bool
- func IsPathExist(path string) (bool, error)
- func MapToStruct(mapData interface{}, structData interface{}) (err error)
- func MkDir(dir string) (err error)
- func NewUUID() (string, error)
- func PKCS7UnPadding(data []byte) []byte
- func ReverseString(str string) string
- func SliceMapToStruct(sliceMapData interface{}, sliceStructData interface{}) (err error)
- type SliceData
- func (s *SliceData) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
- func (s *SliceData) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceData) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...) int
- func (s *SliceData) GetValue(idx int) (value interface{})
- func (s *SliceData) QuickSort()
- func (s *SliceData) QuickSortIndexGo(left, right int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceData) Swap(i, j int)
- type SliceInterfacetSort
- func (s *SliceInterfacetSort) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
- func (s *SliceInterfacetSort) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceInterfacetSort) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...) int
- func (s *SliceInterfacetSort) QuickSort()
- func (s *SliceInterfacetSort) QuickSortIndexGo(left, right int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceInterfacetSort) Swap(i, j int)
- type SliceStructBaseData
- func (s *SliceStructBaseData) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
- func (s *SliceStructBaseData) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceStructBaseData) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...) int
- func (s *SliceStructBaseData) GetValue(idx int) (value interface{})
- func (s *SliceStructBaseData) QuickSort()
- func (s *SliceStructBaseData) QuickSortIndexGo(left, right int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceStructBaseData) Swap(i, j int)
- type SliceStructData
- func (s *SliceStructData) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
- func (s *SliceStructData) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceStructData) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...) int
- func (s *SliceStructData) GetValue(idx int) (value interface{})
- func (s *SliceStructData) QuickSort()
- func (s *SliceStructData) QuickSortIndexGo(left, right int, compFunc func(data1, data2 interface{}, isAsc bool) bool, ...)
- func (s *SliceStructData) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToString ¶
转换字符编码, "GBK", "UTF-8",GB18030 ,HZGB2312的转换 s := ConvertToString(result, "GBK", "UTF-8") s := ConvertToString(result, "UTF-8", "GBK")
func GetZoneTime ¶
根据时区和字符串时间,得到指定时区的时间 GetZoneTime("America/Cordoba", str) GetZoneTime("Asia/Shanghai", str)
func MapToStruct ¶
func MapToStruct(mapData interface{}, structData interface{}) (err error)
将数据是map转为struct,结构体必须是指针.注意:结构体首字母要大写.
func SliceMapToStruct ¶
func SliceMapToStruct(sliceMapData interface{}, sliceStructData interface{}) (err error)
将数据是[]map转为[]struct.注意:结构体首字母要大写.第二个参数要初始化空的跟第一个参数一样大小.
Types ¶
type SliceData ¶
type SliceData struct { Data interface{} //需要排序的切片 IsAsc bool //是否升序(true升序,false降序) CompFunc func(data1, data2 interface{}, isAsc bool) bool //用于比较两个数的函数 }
(注意排序对象是:interface{})数据是切片(例如:[]int,[]string,[]int64等),以接口接收切片对象,排序对象是,字符串切片,整型切片,浮点切片
func NewSliceDataSort ¶
func (*SliceData) BinarySearchSort ¶
func (s *SliceData) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
二分法插入排序.(升序排序)[用在内存中,不要用在硬盘等外存中,例如硬盘文件,顺序更快.]
func (*SliceData) BinarySearchSortIndex ¶
func (s *SliceData) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
对指定区间数据,利用二分法插入排序.
func (*SliceData) FindLocation ¶
func (s *SliceData) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool) int
二分法插入排序,查找位置.(升序排序).start开始位置,end结束位置,cur当前位置
type SliceInterfacetSort ¶
type SliceInterfacetSort struct { Data []interface{} //需要排序的切片 IsAsc bool //是否升序(true升序,false降序) CompFunc func(data1, data2 interface{}, isAsc bool) bool //用于比较两个数的函数 }
(注意排序对象是:[]interface{})数据是切片,切片中每个数据是接口,切片的具体数据可以是,字符串,整型,浮点点的切片.
func NewSliceInterfacetSort ¶
func NewSliceInterfacetSort(data []interface{}, isAsc bool) (sortObj *SliceInterfacetSort)
func (*SliceInterfacetSort) BinarySearchSort ¶
func (s *SliceInterfacetSort) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
二分法插入排序.(升序排序)[用在内存中,不要用在硬盘等外存中,例如硬盘文件,顺序更快.]
func (*SliceInterfacetSort) BinarySearchSortIndex ¶
func (s *SliceInterfacetSort) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
对指定区间数据,利用二分法插入排序.
func (*SliceInterfacetSort) FindLocation ¶
func (s *SliceInterfacetSort) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool) int
二分法插入排序,查找位置.(升序排序).start开始位置,end结束位置,cur当前位置
func (*SliceInterfacetSort) QuickSortIndexGo ¶
func (s *SliceInterfacetSort) QuickSortIndexGo(left, right int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
快速排序,递归
type SliceStructBaseData ¶
type SliceStructBaseData struct { Data interface{} //需要排序的切片 SortStructField int //以结构体中字段索引排序. IsAsc bool //是否升序(true升序,false降序) CompFunc func(data1, data2 interface{}, isAsc bool) bool //用于比较两个数的函数 }
以切片中结构体字段排序,切片中数据是指针结构体(结构体可以是指针结构体,也可以不是指针结构体)(结构体中是基础类型和指针类型) (注意排序对象是:interface{})数据是切片,切片中每个数据是指针结构体.以结构体中字段索引号排序.(注意结构体首字母要大写)
func NewSliceStructBaseData ¶
func NewSliceStructBaseData(data interface{}, sortStructField int, isAsc bool) (sortObj *SliceStructBaseData, err error)
func (*SliceStructBaseData) BinarySearchSort ¶
func (s *SliceStructBaseData) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
二分法插入排序.(升序排序)[用在内存中,不要用在硬盘等外存中,例如硬盘文件,顺序更快.]
func (*SliceStructBaseData) BinarySearchSortIndex ¶
func (s *SliceStructBaseData) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
对指定区间数据,利用二分法插入排序.
func (*SliceStructBaseData) FindLocation ¶
func (s *SliceStructBaseData) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool) int
二分法插入排序,查找位置.(升序排序).start开始位置,end结束位置,cur当前位置
func (*SliceStructBaseData) GetValue ¶
func (s *SliceStructBaseData) GetValue(idx int) (value interface{})
获取切片的数据
func (*SliceStructBaseData) QuickSort ¶
func (s *SliceStructBaseData) QuickSort()
func (*SliceStructBaseData) QuickSortIndexGo ¶
func (s *SliceStructBaseData) QuickSortIndexGo(left, right int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
快速排序,递归
type SliceStructData ¶
type SliceStructData struct { Data interface{} //需要排序的切片 SortStructField int //以结构体中字段索引排序. IsAsc bool //是否升序(true升序,false降序) CompFunc func(data1, data2 interface{}, isAsc bool) bool //用于比较两个数的函数 SwapFunc func(data interface{}, i, j int) //用于交换两个数的函数 }
以切片中结构体字段排序,切片中数据是结构体(结构体可以是指针结构体,也可以不是指针结构体)(结构体中可以是所有类型) (注意排序对象是:interface{})数据是切片,切片中每个数据是结构体.以结构体中字段索引号排序.(注意结构体首字母要大写)
func NewSliceStructDataSort ¶
func NewSliceStructDataSort(data interface{}, sortStructField int, isAsc bool, swapFunc func(data interface{}, i, j int)) (sortObj *SliceStructData, err error)
func (*SliceStructData) BinarySearchSort ¶
func (s *SliceStructData) BinarySearchSort(compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
二分法插入排序.(升序排序)[用在内存中,不要用在硬盘等外存中,例如硬盘文件,顺序更快.]
func (*SliceStructData) BinarySearchSortIndex ¶
func (s *SliceStructData) BinarySearchSortIndex(start, end int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
对指定区间数据,利用二分法插入排序.
func (*SliceStructData) FindLocation ¶
func (s *SliceStructData) FindLocation(start, end, cur int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool) int
二分法插入排序,查找位置.(升序排序).start开始位置,end结束位置,cur当前位置
func (*SliceStructData) GetValue ¶
func (s *SliceStructData) GetValue(idx int) (value interface{})
获取切片的数据
func (*SliceStructData) QuickSort ¶
func (s *SliceStructData) QuickSort()
func (*SliceStructData) QuickSortIndexGo ¶
func (s *SliceStructData) QuickSortIndexGo(left, right int, compFunc func(data1, data2 interface{}, isAsc bool) bool, isAsc bool)
快速排序,递归