qxCommon

package
v0.0.80 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HttpClient = &http.Client{
		Timeout: 30 * time.Second,
	}
)

注意client 本身是连接池,不要每次请求时创建client

Functions

func Arr2Str

func Arr2Str(strings []string) string

func BindAndCheck

func BindAndCheck(ctx *gin.Context, data interface{}) error

func BoolToString

func BoolToString(bool2 bool) string

func CalculateAge

func CalculateAge(birthday string) int

func CalculateAgeTime

func CalculateAgeTime(birthday time.Time) int

func CheckNotExist

func CheckNotExist(src string) bool

CheckNotExist check if the file exists

func CheckPermission

func CheckPermission(src string) bool

CheckPermission check if the file has permission

func CopyDir

func CopyDir(srcPath, desPath string) error

func CopyFile

func CopyFile(src, des string) (written int64, err error)

使用io.Copy

func CreatNestedFile

func CreatNestedFile(path string) (*os.File, error)

CreatNestedFile 给定path创建文件,如果目录不存在就递归创建

func DelFilelist

func DelFilelist(path string)

func DistributeFile

func DistributeFile(url string, params map[string]string, nameField, path string) ([]byte, error)

func Exists

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func ExtractCNAndENAndNum added in v0.0.73

func ExtractCNAndENAndNum(s string) []string

func ExtractDomain added in v0.0.62

func ExtractDomain(rawURL string) (string, error)

func ExtractPath added in v0.0.62

func ExtractPath(rawURL string) (string, error)

func ExtractScheme added in v0.0.62

func ExtractScheme(rawURL string) (string, error)

func FileIsExisted

func FileIsExisted(filename string) bool

func FlatToNested added in v0.0.50

func FlatToNested(input map[string]interface{}) map[string]interface{}

func GenValidateCode

func GenValidateCode(width int) string

func GenerateClientId

func GenerateClientId() string

func GenerateClientSecretHex

func GenerateClientSecretHex() string

func GenerateRandHex

func GenerateRandHex(num int) string

func GetClientIP

func GetClientIP(ctx context.Context) (string, error)

func GetExt

func GetExt(fileName string) string

GetExt get the file ext

func GetSize

func GetSize(f multipart.File) (int, error)

GetSize get the file size

func Int2Str

func Int2Str(inter int) string

Int2Str int类型转string类型

func Int642Str

func Int642Str(inter int64) string

Int2Str int64类型转string类型 精确到后2位 精确到后4位

func Int64Str

func Int64Str(inter int64) string

func IsDouyinClient added in v0.0.72

func IsDouyinClient(userAgent string) bool

func IsEmpty

func IsEmpty(name string) (bool, error)

IsEmpty 返回给定目录是否为空目录

func IsMobile added in v0.0.72

func IsMobile(userAgent string) bool

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

IsNotExistMkDir create a directory if it does not exist

func IsWxClient added in v0.0.72

func IsWxClient(userAgent string) bool

func MakeDir

func MakeDir(dir string) error

func MaskPhoneDynamic

func MaskPhoneDynamic(phone string) string

func MaskPhoneWithRegex

func MaskPhoneWithRegex(phone string) string

func MkDir

func MkDir(src string) error

MkDir create a directory

func Mkdir

func Mkdir(path string) error

CreatNestedFile 给定path创建文件,如果目录不存在就递归创建

func MustOpen

func MustOpen(fileName, filePath string) (*os.File, error)

MustOpen maximize trying to open the file

func Open

func Open(name string, flag int, perm os.FileMode) (*os.File, error)

Open a file according to a specific mode

func PrintMemoryUsage

func PrintMemoryUsage()

func RandInt

func RandInt(min, max int) int

func RandInt64

func RandInt64(min, max int64) int

func RandStringRunes

func RandStringRunes(n int) string

RandStringRunes 返回随机字符串

func Replace

func Replace(table map[string]string, s string) string

Replace 根据替换表执行批量替换

func ReturnSpecifyMonth

func ReturnSpecifyMonth(year, month int) (time.Time, time.Time)

TODO: 获取当月的最后第一天或者最后一天

func ReturnSpecifyYear

func ReturnSpecifyYear(year int) (time.Time, time.Time)

TODO: 获取当年的最后第一天或者最后一天

func Sha1

func Sha1(str string) string

进行Sha1编码

func SliceInt2Str

func SliceInt2Str(inters interface{}) string

Slice2Str string类型转Int64类型

func SplitAndDedup added in v0.0.73

func SplitAndDedup(s string) []string

func SplitBySymbolsAndDedup added in v0.0.73

func SplitBySymbolsAndDedup(s string) []string

func Str2Float64

func Str2Float64(in string) float64

func Str2Int

func Str2Int(inter string) int

Str2Int string类型转Int类型

func Str2Int64

func Str2Int64(inter string) int64

Str2Int64 string类型转Int64类型

func Str2Uint

func Str2Uint(inter string) uint

Str2Int string类型转Int类型

func Str2Uint32

func Str2Uint32(inter string) uint32

func StringToBool

func StringToBool(string2 string) bool

func UploadFile

func UploadFile(url string, params map[string]string, nameField, fileName string, file io.Reader) ([]byte, error)

Types

type WeChatShareConfig

type WeChatShareConfig struct {
	AppId     string   `json:"AppId"`
	Timestamp int64    `json:"Timestamp"`
	NonceStr  string   `json:"NonceStr"`
	Debug     bool     `json:"Debug"`
	JsApiList []string `json:"JsApiList"`
	Signature string   `json:"Signature"`
}

func GetWeChatShareConfig

func GetWeChatShareConfig(debug bool, ticket, shareLink, appid string, JsApiList []string) WeChatShareConfig

Jump to

Keyboard shortcuts

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