golib

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

golib

func

Documentation

Index

Constants

View Source
const (
	ROUNDING_MODE_FLOOR = 0
	ROUNDING_MODE_ROUND = 1
	ROUNDING_MODE_CELL  = 2
)
View Source
const (
	Year        = "06"
	LongYear    = "2006"
	Month       = "Jan"
	ZeroMonth   = "01"
	NumMonth    = "1"
	LongMonth   = "January"
	Day         = "2"
	ZeroDay     = "02"
	UnderDay    = "_2"
	WeekDay     = "Mon"
	LongWeekDay = "Monday"
	Hour        = "15"
	ZeroHour12  = "03"
	Hour12      = "3"
	Minute      = "4"
	ZeroMinute  = "04"
	Second      = "5"
	ZeroSecond  = "05"
)
View Source
const (
	CHINESE_DATE_LONG_FORMAT = "2006-01-02 15:04:05"
	CHINESE_DATE_SHOT_FORMAT = "2006-01-01 15:04:05"
)

自定义

Variables

This section is empty.

Functions

func ArrayColumn added in v1.0.6

func ArrayColumn(array interface{}, columnKey string) ([]interface{}, error)

获取数组中某个字段的值的构成的数组指针

func ArrayStringColumn added in v1.0.6

func ArrayStringColumn(array interface{}, columnKey string) ([]string, error)

获取数组中某个字段的值(string 类型)的构成的数组指针

func Date added in v1.0.4

func Date(layout string, t time.Time) string

*

  • 将time.Time类型按字符串Y-m-d H:i:s格式格式化
  • t 要格式化的时间
  • layout 要格式化的时间格式 Y-m-d H:i:s、 Y-m-d等等

func DeleteFile added in v1.0.4

func DeleteFile(fileName string) error

删除文件

func DoubleMd5Encrypt added in v1.0.4

func DoubleMd5Encrypt(data string) string

Double Md5 Encrypt

func Empty added in v1.0.4

func Empty(data interface{}) bool

判断data是否为空

func Explode added in v1.0.4

func Explode(separator string, str string) map[interface{}]interface{}

*

  • separator 必需。规定在哪里分割字符串。
  • str 必需。要分割的字符串。
  • limit 可选。规定所返回的数组元素的数目。 可能的值:
  • 大于 0 - 返回包含最多 limit 个元素的数组
  • 小于 0 - 返回包含除了最后的 -limit 个元素以外的所有元素的数组
  • 0 - 返回包含一个元素的数组

func FloatScale added in v1.0.4

func FloatScale(f float64, scale, roundMode int) float64

func GetFile added in v1.0.4

func GetFile(path string) os.FileInfo

获取路径对应的文件

func GetFileSize added in v1.0.4

func GetFileSize(infoPath string) int64

获取文件大小

func GetKindOfData added in v1.0.6

func GetKindOfData(data interface{}) string

func GetSliceColumnMapArray added in v1.0.6

func GetSliceColumnMapArray(data interface{}, columnKey string) (map[string]interface{}, error)

map数组中的值根据需要使用类型断言转换 columnKey需是唯一值不重复

func GetStructColumnValueByColumnKey added in v1.0.6

func GetStructColumnValueByColumnKey(data interface{}, columnKey string) interface{}

Get Struct column value by (struct column) key data should be a Struct or a (Struct) Ptr

func GetStructKey added in v1.0.4

func GetStructKey(data map[string]interface{}) string

func GetTime added in v1.0.4

func GetTime() string

获取当前时间的日期格式字符串

func GroupingMapDataByColumnKeyValue added in v1.0.6

func GroupingMapDataByColumnKeyValue(data interface{}, columnKey string) (map[string][]interface{}, error)

根据数组中某个字段的值分组 返回的是多个数组映射

func HttpGet added in v1.0.4

func HttpGet(url string) ([]byte, error)

func HttpPost added in v1.0.4

func HttpPost() error

func HttpsGet added in v1.0.4

func HttpsGet(url string) ([]byte, error)

func InArray added in v1.0.4

func InArray(array interface{}, value interface{}) bool

判断数据是否在一个数组中 dataType 是value的数据类型 如果value和array切片(或数组)中值的类型不同则函数会返回false

func IsDir added in v1.0.4

func IsDir(path string) bool

根据传入路径判断文件是否是目录

func IsExist added in v1.0.4

func IsExist(path string) bool

根据传入路径判断文件或目录是否存在

func IsFile added in v1.0.4

func IsFile(path string) bool

根据传入路径判断是否是文件

func IsWritable added in v1.0.4

func IsWritable(path string) bool

根据传入路径判断文件是否可写

func JsonDecode added in v1.0.4

func JsonDecode(str string, data interface{}) error

@param str json字符串 @param data 解析的数据结构 传入data的引用

func JsonEncode added in v1.0.4

func JsonEncode(data interface{}) string

func Md5 added in v1.0.4

func Md5(str string) string

func RandomCreateBytes added in v1.0.4

func RandomCreateBytes(n int, alphabets ...byte) []byte

RandomCreateBytes generate random []byte by specify chars.

func Sha256Encrypt added in v1.0.4

func Sha256Encrypt(key string) string

Sha256 Encrypt

func SizeFormat added in v1.0.4

func SizeFormat(size float64) string

func Sort added in v1.0.4

func Sort(key string, maps []map[string]interface{}) []map[string]interface{}

根据map类型的切片的某个键值排序

func StrToTime added in v1.0.4

func StrToTime(str string) (*time.Time, error)

将日期时间格式的字符串转为 time.Time类型

func ToString added in v1.0.4

func ToString(data interface{}) string

将数据的类型强制转换为string类型

Types

type MapsSort added in v1.0.4

type MapsSort struct {
	Key     string
	MapList []map[string]interface{}
}

func (*MapsSort) Len added in v1.0.4

func (m *MapsSort) Len() int

func (*MapsSort) Less added in v1.0.4

func (m *MapsSort) Less(i, j int) bool

func (*MapsSort) Swap added in v1.0.4

func (m *MapsSort) Swap(i, j int)

type RedisCache added in v1.0.4

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

func (*RedisCache) Close added in v1.0.4

func (rc *RedisCache) Close() error

func (*RedisCache) GetGlobalCache added in v1.0.4

func (rc *RedisCache) GetGlobalCache(key string) (string, error)

func (*RedisCache) SetGlobalCache added in v1.0.4

func (rc *RedisCache) SetGlobalCache(key string, value interface{}, expiration time.Duration) error

type RedisCacher added in v1.0.4

type RedisCacher interface {
	SetGlobalCache(key string, value interface{}, expiration time.Duration) error
	GetGlobalCache(key string) (string, error)
	Close() error
}

func NewRedisCacher added in v1.0.4

func NewRedisCacher(Options *redis.Options) (RedisCacher, error)

生成redis缓存操作接口

type TempInfo added in v1.0.4

type TempInfo struct {
	ChunkSize int64  `json:"ChunkSize"`
	FileHash  string `json:"FileHash"`
	FileId    string `json:"FileId"`
	FileName  string `json:"FileName"`
	FileSize  int64  `json:"FileSize"`
	Label     string `json:"Label"`
}

func GetJsonFileInfo added in v1.0.4

func GetJsonFileInfo(infoPath string) (temp TempInfo, n int64)

获取文件中的json数据

Jump to

Keyboard shortcuts

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