pkg

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTagName   = "json"
	DefaultDescTag   = "description"
	DefaultPageSize  = 5000
	DefaultSheetSize = 100000
	DefaultLimitSize = 100000
	DefaultSheetName = "Sheet"
)
View Source
const (
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"
)

Variables

This section is empty.

Functions

func CheckExist added in v0.4.1

func CheckExist(src string) bool

CheckExist 检查文件是否存在

func CheckPermission added in v0.4.1

func CheckPermission(src string) bool

CheckPermission 检查文件权限

func DefaultFieldFunc added in v1.1.20

func DefaultFieldFunc(obj any, tag string) []string

func DefaultHeaderFunc added in v1.1.20

func DefaultHeaderFunc(ctx context.Context, l LangFunc, excel *excelize.File, fieldList []string, translateMap map[string]string) (headerCols []interface{}, err error)

func DefaultStatusFunc added in v1.1.20

func DefaultStatusFunc(ctx context.Context, l LangFunc, fieldList []string, translateMap map[string]string) (statusEnums map[string]map[string]string)

func DefaultTranslateFunc added in v1.1.20

func DefaultTranslateFunc(obj any, tag, desc string) map[string]string

func Dsn added in v0.4.1

func Dsn(m *Mysql) string

func FileCreate

func FileCreate(content bytes.Buffer, name string)

func FileMonitoringById

func FileMonitoringById(ctx context.Context, filePth string, id string, group string, hookfn func(context.Context, string, string, []byte))

func Get added in v0.4.1

func Get() []string

func GetCurrentPath

func GetCurrentPath() string

GetCurrentPath 获取当前路径,比如:E:/abc/data/test

func GetDBType added in v0.4.1

func GetDBType(link string) string

func GetExt added in v0.4.1

func GetExt(fileName string) string

GetExt 获取文件后缀

func GetFileSize

func GetFileSize(filename string) int64

GetFileSize 获取文件大小

func GetImgType added in v0.4.1

func GetImgType(p string) (string, error)

GetImgType 获取Img文件类型

func GetLocalHost

func GetLocalHost() string

GetLocalHost 获取局域网ip地址

func GetLocation

func GetLocation(ctx context.Context, ip string) string

GetLocation 获取外网ip地址

func GetNonEmptyFields added in v1.1.20

func GetNonEmptyFields(obj interface{}, tagName string) (map[string]any, error)

GetNonEmptyFields returns a map of non-empty fields of a struct

func GetSize added in v0.4.1

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

GetSize 获取文件大小

func GetTags added in v1.1.20

func GetTags(obj any, tagName string) []string

GetTags returns a slice of any tags of a struct

func GetTagsMap added in v1.1.20

func GetTagsMap(obj any, tagName, vTagName string) map[string]string

GetTagsMap returns a map of any tags of a struct

func GetType added in v0.4.1

func GetType(p string) (string, error)

GetType 获取文件类型

func InSlice added in v1.1.24

func InSlice(needle string, haystack []string) bool

InSlice returns true if the needle string is found in the haystack slice

func IsNotExistMkDir added in v0.4.1

func IsNotExistMkDir(src string) error

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

func IsSlice added in v1.1.25

func IsSlice(obj any) bool

func MkDir added in v0.4.1

func MkDir(src string) error

MkDir 新建文件夹

func Open added in v0.4.1

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

Open 打开文件

func PathCreate

func PathCreate(dir string) error

func PathExist

func PathExist(addr string) bool

PathExist 判断目录是否存在

func Round

func Round(f float64, n int) float64

func SaveUploadedFile

func SaveUploadedFile(file *multipart.FileHeader, dst string) error

SaveUploadedFile uploads the form file to specific dst.

func WithExportOptionsDescTag added in v1.1.20

func WithExportOptionsDescTag(tag string) func(*ExportOptions)

func WithExportOptionsErrorFunc added in v1.1.23

func WithExportOptionsErrorFunc(f ErrorFunc) func(*ExportOptions)

func WithExportOptionsFieldFunc added in v1.1.20

func WithExportOptionsFieldFunc(f FieldFunc) func(*ExportOptions)

func WithExportOptionsFileName added in v1.1.20

func WithExportOptionsFileName(fileName string) func(*ExportOptions)

func WithExportOptionsFinishFunc added in v1.1.23

func WithExportOptionsFinishFunc(f FinishFunc) func(*ExportOptions)

func WithExportOptionsGraphicOptions added in v1.1.24

func WithExportOptionsGraphicOptions(g *GraphicOptions) func(*ExportOptions)

func WithExportOptionsHeaderFunc added in v1.1.20

func WithExportOptionsHeaderFunc(f HeaderFunc) func(*ExportOptions)

func WithExportOptionsI18n added in v1.1.23

func WithExportOptionsI18n(i18n *gi18n.Manager) func(*ExportOptions)

func WithExportOptionsLimitSize added in v1.1.23

func WithExportOptionsLimitSize(limit int) func(*ExportOptions)

func WithExportOptionsListFunc added in v1.1.20

func WithExportOptionsListFunc(f ListFunc) func(*ExportOptions)

func WithExportOptionsPageSize added in v1.1.20

func WithExportOptionsPageSize(pageSize int) func(*ExportOptions)

func WithExportOptionsParamsFunc added in v1.1.22

func WithExportOptionsParamsFunc(f RawFunc) func(*ExportOptions)

func WithExportOptionsPictureFunc added in v1.1.24

func WithExportOptionsPictureFunc(f PictureFunc) func(*ExportOptions)

func WithExportOptionsPictureKeys added in v1.1.24

func WithExportOptionsPictureKeys(keys []string) func(*ExportOptions)

func WithExportOptionsSheetPrefix added in v1.1.20

func WithExportOptionsSheetPrefix(prefix string) func(*ExportOptions)

func WithExportOptionsSheetSize added in v1.1.20

func WithExportOptionsSheetSize(sheetSize int) func(*ExportOptions)

func WithExportOptionsStatusFunc added in v1.1.20

func WithExportOptionsStatusFunc(f StatusFunc) func(*ExportOptions)

func WithExportOptionsSummaryFunc added in v1.1.20

func WithExportOptionsSummaryFunc(f RawFunc) func(*ExportOptions)

func WithExportOptionsTagName added in v1.1.20

func WithExportOptionsTagName(tag string) func(*ExportOptions)

func WithExportOptionsTotalFunc added in v1.1.20

func WithExportOptionsTotalFunc(f TotalFunc) func(*ExportOptions)

func WithExportOptionsTranslateFunc added in v1.1.20

func WithExportOptionsTranslateFunc(f TranslateFunc) func(*ExportOptions)

Types

type ErrorFunc added in v1.1.23

type ErrorFunc func(ctx context.Context, err error) error

type Export added in v1.1.20

type Export struct {
	// contains filtered or unexported fields
}

func NewExport added in v1.1.20

func NewExport(ctx context.Context, optionFuncs ...func(*ExportOptions)) *Export

func (*Export) Run added in v1.1.20

func (e *Export) Run() (err error)

type ExportOptions added in v1.1.20

type ExportOptions struct {
	FileName      string
	PageSize      int
	SheetSize     int
	LimitSize     int
	SheetPrefix   string
	TagName       string
	DescTag       string
	PictureKeys   []string
	FieldFunc     FieldFunc
	TranslateFunc TranslateFunc
	StatusFunc    StatusFunc
	HeaderFunc    HeaderFunc
	TotalFunc     TotalFunc
	ListFunc      ListFunc
	SummaryFunc   RawFunc
	ParamsFunc    RawFunc
	FinishFunc    FinishFunc
	ErrorFunc     ErrorFunc
	PictureFunc   PictureFunc

	GraphicOptions *GraphicOptions
	// contains filtered or unexported fields
}

type FieldFunc added in v1.1.20

type FieldFunc func(ctx context.Context) []string

type FinishFunc added in v1.1.23

type FinishFunc func(ctx context.Context) error

type GraphicOptions added in v1.1.24

type GraphicOptions excelize.GraphicOptions

type HeaderFunc added in v1.1.20

type HeaderFunc func(ctx context.Context, excel *excelize.File) ([]interface{}, error)

type LangFunc added in v1.1.23

type LangFunc func(ctx context.Context, key string) string

type ListFunc added in v1.1.20

type ListFunc func(ctx context.Context, page, pageSize int) ([]interface{}, error)

type LocationResp

type LocationResp struct {
	Status      string  `json:"status"` // success
	Country     string  `json:"country"`
	CountryCode string  `json:"countryCode"`
	Region      string  `json:"region"`
	RegionName  string  `json:"regionName"`
	City        string  `json:"city"`
	Zip         string  `json:"zip"`
	Lat         float64 `json:"lat"`
	Lon         float64 `json:"lon"`
	Timezone    string  `json:"timezone"`
	Isp         string  `json:"isp"`
	Org         string  `json:"org"`
	As          string  `json:"as"`
	Query       string  `json:"query"`
}

type Mysql added in v0.4.1

type Mysql struct {
	Path          string `json:"path" yaml:"path"`
	Config        string `json:"config" yaml:"config"`
	Dbname        string `json:"dbname" yaml:"db-name"`
	Username      string `json:"username" yaml:"username"`
	Password      string `json:"password" yaml:"password"`
	MaxIdleConnes int    `json:"maxIdleConnes" yaml:"max-idle-connes"`
	MaxOpenConnes int    `json:"maxOpenConnes" yaml:"max-open-connes"`
	LogMode       bool   `json:"logMode" yaml:"log-mode"`
	LogZap        string `json:"logZap" yaml:"log-zap"`
}
func GetByLink(link string) Mysql

type PictureFunc added in v1.1.24

type PictureFunc func(ctx context.Context, url string) string

type RawFunc added in v1.1.20

type RawFunc func(ctx context.Context) (any, error)

type RawStruct added in v1.1.20

type RawStruct struct {
	FieldList   []string
	HeaderCols  []interface{}
	StatusEnums map[string]map[string]string
	Obj         any
}

type ReplaceHelper

type ReplaceHelper struct {
	Root    string //路径
	OldText string //需要替换的文本
	NewText string //新的文本
}

func (*ReplaceHelper) DoWork

func (h *ReplaceHelper) DoWork() error

type StatusFunc added in v1.1.20

type StatusFunc func(ctx context.Context) map[string]map[string]string

type TotalFunc added in v1.1.20

type TotalFunc func(ctx context.Context) (int, error)

type TranslateFunc added in v1.1.20

type TranslateFunc func(ctx context.Context) map[string]string

Directories

Path Synopsis
tus
filelocker
Package filelocker provide an upload locker based on the local file system.
Package filelocker provide an upload locker based on the local file system.
filestore
Package filestore provide a storage backend based on the local file system.
Package filestore provide a storage backend based on the local file system.
memorylocker
Package memorylocker provides an in-memory locking mechanism.
Package memorylocker provides an in-memory locking mechanism.
uid

Jump to

Keyboard shortcuts

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