utils

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyImg

func CopyImg(img image.Image) image.Image

func Draw

func Draw(img image.Image, r image.Image, x, y, w, h int) image.Image

func EncodeImg

func EncodeImg(img image.Image) []byte

func FindAllString

func FindAllString(exp string, str string) []string

func FindString

func FindString(exp string, str string) string

func GetAppname

func GetAppname() string

获取app名称

func GetCurrentDirectory

func GetCurrentDirectory() string

@title createDir @description 获取运行地址 @auth (2020/04/05 20:22) @param path string

func IF

func IF(condition bool, trueval, falseval interface{}) interface{}

三元运算符

func ImgToBase64

func ImgToBase64(img image.Image) string

func ImgToReader

func ImgToReader(img image.Image) (*bytes.Reader, int64)

func LoadImg

func LoadImg(r io.Reader) (image.Image, string, error)

加载图片 返回 图片、图片类型、错误

func MD5V

func MD5V(str []byte) string

func MatchEmail

func MatchEmail(email string) bool

func MatchPhone

func MatchPhone(phone string) bool

func MatchString

func MatchString(exp string, str string) bool

func Md5v

func Md5v(str []byte) string

func MkdirIfNotExist

func MkdirIfNotExist(dir string) error

创建目录

func RandomString

func RandomString(n int, allowedChars ...rune) string

RandomString returns a random string with a fixed length

func SaveImg

func SaveImg(img image.Image, path string, mod string) error

func SliceStringContains

func SliceStringContains(a []string, b string) bool

slice contains

func TrimmingImage

func TrimmingImage(src image.Image, x, y, w, h int) (image.Image, error)

func Verify

func Verify(st interface{}) (err error)

校验方法 接收两个参数 入参实例,规则map

Types

type BaseModel

type BaseModel struct {
	ID        int            `json:"id" gorm:"primary_key"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	Deleted   gorm.DeletedAt `gorm:"index"`
}

type BaseModelV1

type BaseModelV1 struct {
	CreatedAt time.Time      `json:"created_at" gorm:"type:datetime"`
	UpdatedAt time.Time      `json:"updated_at" gorm:"type:datetime"`
	Deleted   gorm.DeletedAt `gorm:"index"`
}

Jump to

Keyboard shortcuts

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