utils

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 15 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 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 NotExist

func NotExist(src string) bool

NotExist reports whether nothing is at src.

It was called CheckExist and documented as checking existence while returning the opposite, so its one caller compensated by inverting twice. Renamed rather than corrected in place: a caller who had worked the real behaviour out gets a compile error instead of a silent inversion.

func Open

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

Open 打开文件

The caller owns the file and closes it. Closing it here — which a deferred call did — handed back a file that was already closed.

func PathExists

func PathExists(path string) bool

func RemoveRepByMap

func RemoveRepByMap(slc []string) []string

RemoveRepByMap returns slc without its duplicates, keeping first order.

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