util

package module
v0.0.0-...-93b0e25 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

README

ssutil

golang util

Documentation

Index

Constants

View Source
const (

	// Some default converter types for a nicer syntax
	String  string  = ""
	Bool    bool    = false
	Int     int     = 0
	Float32 float32 = 0
	Float64 float64 = 0
)

These flags define options for tag handling

Variables

View Source
var (
	ErrInvalidCopyDestination        = errors.New("copy destination is invalid")
	ErrInvalidCopyFrom               = errors.New("copy from is invalid")
	ErrMapKeyNotMatch                = errors.New("map's key type doesn't match")
	ErrNotSupported                  = errors.New("not supported")
	ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case")
)

Functions

func ArgFilter

func ArgFilter(keys []string) []string

func BuildDir

func BuildDir(absDir string) error

BuildDir 创建目录

func CheckFileIsExist

func CheckFileIsExist(filename string) bool

CheckFileIsExist 检查目录是否存在

func CompressImageResource

func CompressImageResource(data []byte) []byte

func Copy

func Copy(toValue interface{}, fromValue interface{}) (err error)

Copy copy things

func CopyFile

func CopyFile(src, des string) error

func CopyWithOption

func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error)

CopyWithOption copy with option

func DeleteFile

func DeleteFile(absDir string) error

DeleteFile 删除文件或文件夹

func DumpStack

func DumpStack(msg string) string

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory 获取exe所在目录

func GetModelPath

func GetModelPath() string

GetModelPath 获取程序运行目录

func GetPathDirs

func GetPathDirs(absDir string) (re []string)

GetPathDirs 获取目录所有文件夹

func GetPathFiles

func GetPathFiles(absDir string) (re []string)

GetPathFiles 获取目录所有文件

func MoveFile

func MoveFile(from, to string) error

MoveFile 移动文件或文件夹(/结尾)

func ReadFile

func ReadFile(fname string) (src []string)

ReadFile 读取文件

func SaveToFile

func SaveToFile(fname string, src []string, isClear bool) bool

SaveToFile 写入文件

func StructCopy

func StructCopy(from, to interface{})

func ToRealPage

func ToRealPage(Size, pageIdx uint64) (uint64, uint64, error)

func TopageLimit

func TopageLimit(Size, pageIdx uint) (string, error)

func WriteFile

func WriteFile(fname string, src []string, isClear bool) bool

WriteFile 写入文件

Types

type Option

type Option struct {
	// setting this value to true will ignore copying zero values of all the fields, including bools, as well as a
	// struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go)
	IgnoreEmpty bool
	DeepCopy    bool
	Converters  []TypeConverter
}

Option sets copy options

type Page

type Page struct {
	//每页条数
	Size uint64 //`json:"Size"`
	// 页码
	Idx uint64 //`json:"Idx"`
}

func (*Page) Offset

func (p *Page) Offset() uint64

func (*Page) ToRealPage

func (p *Page) ToRealPage() (uint64, uint64, error)

func (*Page) TopageLimit

func (p *Page) TopageLimit() (string, error)

type TypeConverter

type TypeConverter struct {
	SrcType interface{}
	DstType interface{}
	Fn      func(src interface{}) (dst interface{}, err error)
}

Directories

Path Synopsis
Package decimal implements an arbitrary precision fixed-point decimal.
Package decimal implements an arbitrary precision fixed-point decimal.
driver
nolint
nolint
** description("").
** description("").
log
gid
naming
Package snowflake provides a very simple Twitter snowflake generator and parser.
Package snowflake provides a very simple Twitter snowflake generator and parser.
* @Author: * @Date: 2022-12-21 12:39:14 * @LastEditors: Please set LastEditors * @LastEditTime: 2022-12-23 11:23:36 * @Description:
* @Author: * @Date: 2022-12-21 12:39:14 * @LastEditors: Please set LastEditors * @LastEditTime: 2022-12-23 11:23:36 * @Description:

Jump to

Keyboard shortcuts

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