common

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 23 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 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 FileIsExisted

func FileIsExisted(filename string) bool

func GenValidateCode

func GenValidateCode(width 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 IsEmpty

func IsEmpty(name string) (bool, error)

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

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

IsNotExistMkDir create a directory if it does not exist

func MakeDir

func MakeDir(dir string) error

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 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 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 UploadFile

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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