lib

package
v1.0.3 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

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 Date

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

func DeleteFile(fileName string) error

删除文件

func DoubleMd5Encrypt

func DoubleMd5Encrypt(data string) string

Double Md5 Encrypt

func Empty

func Empty(data interface{}) bool

判断data是否为空

func Explode

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

*

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

func FloatScale

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

func GetFile

func GetFile(path string) os.FileInfo

获取路径对应的文件

func GetFileSize

func GetFileSize(infoPath string) int64

获取文件大小

func GetStructKey

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

func GetTime

func GetTime() string

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

func HttpGet

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

func HttpPost

func HttpPost() error

func HttpsGet

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

func InArray

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

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

func IsDir

func IsDir(path string) bool

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

func IsExist

func IsExist(path string) bool

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

func IsFile

func IsFile(path string) bool

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

func IsWritable

func IsWritable(path string) bool

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

func JsonDecode

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

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

func JsonEncode

func JsonEncode(data interface{}) string

func Md5

func Md5(str string) string

func RandomCreateBytes

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

RandomCreateBytes generate random []byte by specify chars.

func Sha256Encrypt

func Sha256Encrypt(key string) string

Sha256 Encrypt

func SizeFormat

func SizeFormat(size float64) string

func Sort

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

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

func StrToTime

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

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

func ToString

func ToString(data interface{}) string

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

Types

type MapsSort

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

func (*MapsSort) Len

func (m *MapsSort) Len() int

func (*MapsSort) Less

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

func (*MapsSort) Swap

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

type RedisCache

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

func (*RedisCache) Close

func (rc *RedisCache) Close() error

func (*RedisCache) GetGlobalCache

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

func (*RedisCache) SetGlobalCache

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

type RedisCacher

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

func NewRedisCacher

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

生成redis缓存操作接口

type TempInfo

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

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