libs

package
v0.0.0-...-d28bcca Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DesEnvKeyName    = "APP_ENCRYPT_DES_KEY"
	DesEncryptErrMsg = "need a multiple of the block size"
	DesDecryptErrMsg = "crypto/cipher: input not full blocks"
)
View Source
const (
	BigNumberK      = 1000
	BigNumberKUnit  = "k"
	BigNumberW      = BigNumberK * 10
	BigNumberWUnit  = "w"
	BigNumberKW     = BigNumberW * BigNumberK
	BigNumberKWUnit = "kw"
	BigNumberWW     = BigNumberKW * BigNumberK
	BigNumberWWUnit = "ww"
)
View Source
const (
	TIMEFORMAT       = "20060102150405"
	NORMALTIMEFORMAT = "2006-01-02 15:04:05"
)
View Source
const (
	Mov = "moov"
	Mat = "mdat"
)
View Source
const (
	BigEndian = false
)
View Source
const (
	PasswordAPPKey = "71e920133ebb7d0a94b9daed8f6c2d9a"
)

Variables

View Source
var (
	BigNumberMapper = []struct {
		Limiter int64
		Unit    string
	}{
		{BigNumberK, BigNumberKUnit},
		{BigNumberW, BigNumberWUnit},
		{BigNumberKW, BigNumberKWUnit},
		{BigNumberWW, BigNumberWWUnit},
	}
)
View Source
var (
	ContainerNotFound = errors.New("not exists in container")
)

Functions

func ArgsAny

func ArgsAny(args []interface{}, defs interface{}) interface{}

func ArgsBool

func ArgsBool(args []bool, defs bool) bool

func ArgsInt

func ArgsInt(args []int, defs int) int

func ArgsIntN

func ArgsIntN(args []int64, defs int64) int64

func ArgsStr

func ArgsStr(args []string, defs string) string

func ArrayFirst

func ArrayFirst(arr []string, defaults ...string) string

ArrayFirst 字符串数组第一个元素

func BigNumberStringer

func BigNumberStringer(num int64) string

大数格式化

func Boolean

func Boolean(str string) bool

func CheckHours

func CheckHours() bool

CheckHours 判断当前时间是否是整点

func CompareTime

func CompareTime(t1, t2 time.Time) bool

CompareTime 比较两个时间大小

func Decimal

func Decimal(f float64, n ...int) float64

func DecimalText

func DecimalText(f float64, n ...int) string

保留 小数位数

func Decrypt

func Decrypt(data string, key ...string) string

解密

func DesDecrypt

func DesDecrypt(decrypted string, key []byte) (string, error)

func DesEncrypt

func DesEncrypt(text string, key []byte) (string, error)

func Encrypt

func Encrypt(data string, key ...string) string

加密

func FileHash

func FileHash(file string) string

func FileSizeTans

func FileSizeTans(size string, unit string) int64

FileSizeTans 文件大小字符串转换

func FormatFileSize

func FormatFileSize(fileSize int64) string

FormatFileSize 文件大小格式化

func GetCdnUrl

func GetCdnUrl(url string, ty OssUrlType) string

func GetConfigApp

func GetConfigApp() *viper.Viper

GetConfigApp 获取 config App

func GetDesKey

func GetDesKey(keys ...string) []byte

func GetEnvBool

func GetEnvBool(key string, def ...bool) bool

func GetEnvFloat

func GetEnvFloat(key string, def ...float64) float64

func GetEnvInt

func GetEnvInt(key string, def ...int) int

func GetEnvOr

func GetEnvOr(key string, def ...string) string

func GetFileType

func GetFileType(file string) string

GetFileType 获取文件类型

func GetHourDiffer

func GetHourDiffer(startTime, endTime string) float32

GetHourDiffer 计算俩个时间差多少小时

func GetId

func GetId(db, collection string, sess *mgo.Session) int64

用户表自增ID

func GetLastJsonErr

func GetLastJsonErr() error

GetLastJsonErr 获取 异常

func GetMP4Duration

func GetMP4Duration(reader io.ReaderAt) (lengthOfTime uint32, err error)

GetMP4Duration 获取视频时长,以秒计

func GetMp4FileDuration

func GetMp4FileDuration(fileName string) (time.Duration, error)

GetMp4FileDuration 获取mp4 时长

func GetNextHourTime

func GetNextHourTime(s string, n int64) string

GetNextHourTime n小时后的时间字符串

func GetNormalTimeString

func GetNormalTimeString(t time.Time) string

GetNormalTimeString 格式化为:2006-01-02 15:04:05

func GetTime

func GetTime() time.Time

GetTime 当前时间

func GetTimeByInt

func GetTimeByInt(t1 int64) time.Time

GetTimeByInt 时间戳转时间

func GetTimeByNormalString

func GetTimeByNormalString(timeStr string) (time.Time, error)

GetTimeByNormalString 标准字符串转时间

func GetTimeByString

func GetTimeByString(timeStr string) (time.Time, error)

GetTimeByString 字符串转时间

func GetTimeMills

func GetTimeMills(t time.Time) int64

GetTimeMills 转为时间戳->毫秒数

func GetTimeString

func GetTimeString(t time.Time) string

GetTimeString 格式化为:20060102150405

func GetTimeUnix

func GetTimeUnix(t time.Time) int64

GetTimeUnix 转为时间戳->秒数

func HashCode

func HashCode(any interface{}) string

func Import

func Import(source string, force ...bool) bool

Import 加载

func InArray

func InArray(value string, array []string, fold ...bool) bool

func Integer

func Integer(v interface{}) (int, bool)

Integer 整型

func IsCnMobile

func IsCnMobile(mobile string) bool

func IsEmail

func IsEmail(email string) bool

func IsExits

func IsExits(file string) bool

func IsIocNotFound

func IsIocNotFound(v interface{}) bool

func IsMobile

func IsMobile(mobile string) bool

func IsNumber

func IsNumber(v interface{}) bool

func Json

func Json() jsonApi.API

func JsonDecode

func JsonDecode(data []byte, bindTo ...interface{}) interface{}

JsonDecode json 解码

func JsonDecodeBy

func JsonDecodeBy(str string, bindTo ...interface{}) interface{}

JsonDecodeBy 解码

func JsonEncode

func JsonEncode(v interface{}) []byte

JsonEncode 编码

func MapMerge

func MapMerge(m ...beego.M) beego.M

func MarkerMobile

func MarkerMobile(mobile string) string

func Md5

func Md5(str string) string

Md5 md5

func Merge

func Merge(m ...map[string]interface{}) map[string]interface{}

func NewHashMapper

func NewHashMapper(v ...interface{}) []interface{}

NewHashMapper 创建hash

func NewIntegerArray

func NewIntegerArray(v ...interface{}) []int

NewIntegerArray 创建hash

func PasswordHash

func PasswordHash(pass string, salt ...string) string

PasswordHash 加密密码

func PasswordVerify

func PasswordVerify(encodePass string, pass string, salt ...string) bool

PasswordVerify 密码验证

func RandFloat64

func RandFloat64(min, max float64) float64

func RandInt

func RandInt(min, max int) int

func RandNumbers

func RandNumbers(len int) string

func RandomAnyWord

func RandomAnyWord(count int) string

func RandomNickName

func RandomNickName(lens ...int) string

func RandomNumLimitN

func RandomNumLimitN(count int) string

func RandomWord

func RandomWord(count int) string

func RandomWords

func RandomWords(count int, words string) string

func RandomZhWords

func RandomZhWords(count int) string

func Shuffle

func Shuffle(arr []interface{}) []interface{}

func UniqueFile

func UniqueFile(file string, root ...string) string

UniqueFile 唯一名文件

func VariableParse

func VariableParse(varStr string, i ...int) string

VariableParse 循环变量

func ZeroPadding

func ZeroPadding(cipherText []byte, blockSize int) []byte

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

Types

type BoxHeader

type BoxHeader struct {
	Size     uint32
	FourType [4]byte
	Size64   uint64
}

BoxHeader 信息头

type CommitId

type CommitId struct {
	Db        string
	TableName string
	Conn      *mgo.Session
	// contains filtered or unexported fields
}

func NewId

func NewId(tableName string, db string, conn *mgo.Session) *CommitId

func (*CommitId) Commit

func (this *CommitId) Commit() error

func (*CommitId) GetId

func (this *CommitId) GetId() int64

func (*CommitId) RollBack

func (this *CommitId) RollBack() error

type ContainerInterface

type ContainerInterface interface {
	Exists(id string) bool
	Reset(name ...string) ContainerInterface
	Get(id string, args ...interface{}) interface{}
	Register(name string, factory func(args ...interface{}) interface{}, force ...bool) ContainerInterface
	GetInstance(name string, args ...interface{}) interface{}
}

func Container

func Container() ContainerInterface

type EnumBool

type EnumBool string
const (
	True  EnumBool = "true"
	Yes   EnumBool = "yes"
	Ok    EnumBool = "ok"
	On    EnumBool = "on"
	One   EnumBool = "1"
	No    EnumBool = "no"
	Not   EnumBool = "not"
	Off   EnumBool = "off"
	Zero  EnumBool = "0"
	False EnumBool = "false"
)

func (EnumBool) Bool

func (enum EnumBool) Bool() bool

func (EnumBool) String

func (enum EnumBool) String() string

func (EnumBool) Type

func (enum EnumBool) Type() bool

type FileSize

type FileSize int64

func (FileSize) Parse

func (this FileSize) Parse(size string) int64

func (FileSize) String

func (this FileSize) String() string

type OssUrlBuilder

type OssUrlBuilder interface {
	GetUrl(ty ...OssUrlType) string
	SetSourceUrl(string) OssUrlBuilder
}

func OssUrl

func OssUrl(url string) OssUrlBuilder

type OssUrlType

type OssUrlType string
const (
	Row           OssUrlType = "row"
	Media         OssUrlType = "medium"
	Big           OssUrlType = "big"
	Small         OssUrlType = "small"
	DefOptFlag               = "@" // 类型参数符号
	OptFlagEnvKey            = "QINNIU_URL_OPT_FLAG"
)

type UrlLoader

type UrlLoader struct {
	Name    string
	Match   func(*url.URL) bool
	Handler func(*url.URL) error
}

UrlLoader url-loader

Jump to

Keyboard shortcuts

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