utils

package
v0.0.1-202406121004 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToFile

func AppendToFile(path string, content []byte) error

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 HmacObj

func HmacObj(data interface{}) 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 ParseTemplate

func ParseTemplate(filepath string, args interface{}) ([]byte, error)

func PathExists

func PathExists(path string) bool

func RemoveRepByMap

func RemoveRepByMap(slc []string) []string

slice去重

func WriteFile

func WriteFile(path string, content []byte) error

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 JSONDate

type JSONDate struct {
	time.Time
}

JSONDate format json time field by myself

func NewJsonDate

func NewJsonDate(t time.Time) *JSONDate

func NewJsonDateNow

func NewJsonDateNow() *JSONDate

func NewJsonDateStr

func NewJsonDateStr(t string) (*JSONDate, error)

func (JSONDate) MarshalJSON

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

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

func (*JSONDate) Scan

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

Scan valueof time.Time

func (*JSONDate) UnmarshalJSON

func (t *JSONDate) UnmarshalJSON(data []byte) (err error)

func (JSONDate) Value

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

Value insert timestamp into mysql need this function.

type JSONTime

type JSONTime struct {
	time.Time
}

JSONTime format json time field by myself

func NewJsonStr

func NewJsonStr(t string) (*JSONTime, error)

func NewJsonTime

func NewJsonTime(t time.Time) *JSONTime

func NewJsonTimeNow

func NewJsonTimeNow() *JSONTime

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) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(data []byte) (err error)

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