utils

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64ToImage

func Base64ToImage(imageBase64 string) ([]byte, error)

func CheckExist

func CheckExist(src string) bool

CheckExist 检查文件是否存在

func CheckPermission

func CheckPermission(src string) bool

CheckPermission 检查文件权限

func GetCurrentTimeStamp

func GetCurrentTimeStamp() int64

func GetDirFiles

func GetDirFiles(dir string) ([]string, error)

func GetExt

func GetExt(fileName string) string

GetExt 获取文件后缀

func GetImgType

func GetImgType(p string) (string, error)

GetImgType 获取Img文件类型

func GetSize

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

GetSize 获取文件大小

func GetType

func GetType(p string) (string, error)

GetType 获取文件类型

func GetUUID

func GetUUID() string

func Hmac

func Hmac(data string) string

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

IsNotExistMkDir 检查文件夹是否存在 如果不存在则新建文件夹

func IsStringEmpty

func IsStringEmpty(str string) bool

func MkDir

func MkDir(src string) error

MkDir 新建文件夹

func Open

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

Open 打开文件

func PathExists

func PathExists(path string) bool

func RemoveRepByMap

func RemoveRepByMap(slc []string) []string

slice去重

Types

type APIException

type APIException struct {
	Code      int         `json:"code"`
	Success   bool        `json:"success"`
	Msg       string      `json:"msg"`
	Timestamp int64       `json:"timestamp"`
	Result    interface{} `json:"result"`
}

api结构体

func AuthError

func AuthError(message string) *APIException

授权错误

func NotFound

func NotFound() *APIException

404 错误

func ParameterError

func ParameterError(message string) *APIException

参数错误

func ResponseJson

func ResponseJson(message string, data interface{}, success bool) *APIException

200

func ServerError

func ServerError() *APIException

500 错误处理

func UnknownError

func UnknownError(message string) *APIException

未知错误

func (*APIException) Error

func (e *APIException) Error() string

实现接口

type JSONTime

type JSONTime struct {
	time.Time
}

JSONTime format json time field by myself

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON on JSONTime format Time field with %Y-%m-%d %H:%M:%S

func (*JSONTime) Scan

func (t *JSONTime) Scan(v interface{}) error

Scan valueof time.Time

func (JSONTime) Value

func (t JSONTime) Value() (driver.Value, error)

Value insert timestamp into mysql need this function.

Jump to

Keyboard shortcuts

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