ez

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 28 Imported by: 3

README

ez框架

介绍

{以下是 Gitee 平台说明,您可以替换此简介 Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 https://gitee.com/enterprises}

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	C_Blue      = 1
	C_Green     = 2
	C_BlueLight = 11
	C_White     = 0
	C_Yellow    = 14
	C_Red       = 4
	C_Pink      = 14
	C_Grey      = 15
	C_Purple    = 5
)
View Source
const (
	LoggerTypeFile    = "file"
	LoggerTypeConsole = "console"
	LoggerTypeMq      = "nsq"
	LoggerTypeNone    = "none"
)

Variables

View Source
var B2M map[string][]Handler
View Source
var B2O map[string]Handler
View Source
var CloseHandle *syscall.LazyProc
View Source
var GLB *globals

下面是一些大家习惯使用的名称的别名方法

View Source
var OnOne = Listen
View Source
var S *serverConfig
View Source
var SetConsoleTextAttribute *syscall.LazyProc
View Source
var Trigger = DispatchToMany
View Source
var TriggerSync = DispatchToManySync

Functions

func AESDecrypt

func AESDecrypt(encrypted []byte, key []byte) (decrypted []byte)

func AESEncrypt

func AESEncrypt(src []byte, key []byte) (encrypted []byte)

func AddTime

func AddTime(cur time.Time, h int, i int, s int) time.Time

func AesDecrypt

func AesDecrypt(encrypted string, key string) string

func AesEncrypt

func AesEncrypt(src string, key string) string

func ArrayToSlice

func ArrayToSlice(array []interface{}) []interface{}

func CamelString

func CamelString(s string) string

func CamelStrings added in v1.0.2

func CamelStrings(in []string) (out []string)

func China

func China() *time.Location

func ChinaSuffix

func ChinaSuffix() string

func CleanPath

func CleanPath(Path string) string

func ColorPrint

func ColorPrint(s string, i int)

func ColorPrintEnd

func ColorPrintEnd()

func ColorPrintStart

func ColorPrintStart(i int)

func ContainsString added in v1.0.1

func ContainsString(src []string, dest string) bool

func Copy

func Copy(from string, to string) error

func CreatRandomInt

func CreatRandomInt(min, max int) int

func CreateConfigFromYml added in v1.0.1

func CreateConfigFromYml(path string, node string, model interface{})

func CreateDirForPath

func CreateDirForPath(Path string) error

func CreateFile

func CreateFile(filePath string, content []byte)

func CreateMapInt

func CreateMapInt() map[int]interface{}

func CreateMapString

func CreateMapString() map[string]interface{}

func CreateOrderSn

func CreateOrderSn(randLen int, prefix string, suffix string) string

func CreateRand

func CreateRand(randLen int) string

func CreateRandString

func CreateRandString(len int) string

func DbCreateFilter

func DbCreateFilter() map[string]interface{}

func Debug

func Debug(v interface{})

func DifferenceStrings added in v1.0.1

func DifferenceStrings(src []string, dest []string) []string

DifferenceStrings 取前者src与后者dest两个字符串列表的差集

func DispatchToMany added in v1.0.1

func DispatchToMany(name string, data interface{}, ctx context.Context)

func DispatchToManySync added in v1.0.1

func DispatchToManySync(name string, data interface{}, ctx context.Context)

func DispatchToOne added in v1.0.1

func DispatchToOne(name string, data interface{}, ctx context.Context)

func FileExist

func FileExist(path string) bool

func FindAndOpen added in v1.0.1

func FindAndOpen(path string) []byte

func Float64ToInt

func Float64ToInt(int64 float64) int

func GetCurrentPath

func GetCurrentPath() string

func GetDate

func GetDate(dateSep string) string

func GetDateD

func GetDateD() string

func GetDateFromTimeYMDHIS

func GetDateFromTimeYMDHIS(t time.Time, dateSep string, timeSep string, dateTimeSep string) string

func GetDateM

func GetDateM() string

func GetDateTime

func GetDateTime() string

func GetDateY

func GetDateY() string

func GetDateYMD

func GetDateYMD(cur ...time.Time) string

func GetDateYMDHIS

func GetDateYMDHIS(dateSep string, timeSep string, dateTimeSep string) string

func GetDayEnd

func GetDayEnd(cur time.Time) time.Time

func GetDayStart

func GetDayStart(cur time.Time) time.Time

func GetDays

func GetDays(year int, month int) (days int)

func GetDebug added in v1.0.1

func GetDebug() bool

func GetLine

func GetLine() int

func GetMonthEnd

func GetMonthEnd(cur time.Time) time.Time

func GetMonthStart

func GetMonthStart(cur time.Time) time.Time

func GetTime

func GetTime(timeSep string) string

func HasError

func HasError(e error, other ...string) bool

func HasSameWord

func HasSameWord(findIn string, find string) bool

*

  • @Description: 检测两组用空格分隔的字符串是否有相同的单词
  • @receiver this
  • @param findIn 原始字符串
  • @param find 要搜索的字符串
  • @return bool

func HmacHs256

func HmacHs256(message string, secret string) string

func Int64ToInt

func Int64ToInt(int64 int64) int

func IntersectionStrings added in v1.0.1

func IntersectionStrings(src []string, dest []string) []string

IntersectionStrings 取两个字符串列表的交集

func IsHasSame

func IsHasSame(slice1 []string, slice2 []string) bool

func IsInArray

func IsInArray(array []interface{}, find interface{}) int

func IsStringInSlice

func IsStringInSlice(find string, findIn []string) bool

func JsonLog

func JsonLog(v interface{})

func Lcfirst

func Lcfirst(str string) string

func LcfirstArr added in v1.0.1

func LcfirstArr(in []string) (out []string)

func Listen added in v1.0.1

func Listen(name string, handler Handler)

func ListenJoin added in v1.0.1

func ListenJoin(name string, handler Handler)

func Mapper

func Mapper(src interface{}, key string, v interface{}) interface{}

func Match

func Match(str string, pattern string) bool

func MatchAll

func MatchAll(str string, pattern string) [][]string

func Md5

func Md5(str string) string

func Now

func Now() *time.Time

func Pow

func Pow(x int, n int) int

func PrintError

func PrintError(e error, other ...string) bool

func PrintInfo

func PrintInfo(other ...string)

func PrintLine

func PrintLine()

func PrintSuccess

func PrintSuccess(other ...string)

func PrintWarning

func PrintWarning(other ...string)

func ReadFile

func ReadFile(path string) []byte

func ReplaceAll

func ReplaceAll(str string, pattern string, replace string) string

func Replaces

func Replaces(toReplace string, froms []string, tos []string) (rst string)

func SHA256

func SHA256(message []byte) string

func SetDebug added in v1.0.1

func SetDebug(debug bool)

func ShowColor

func ShowColor()

func SliceReverse

func SliceReverse(s Slice) []interface{}

func SnakeString

func SnakeString(s string) string

func SnakeStrings added in v1.0.2

func SnakeStrings(in []string) (out []string)

func StringArrayUnique

func StringArrayUnique(orgSlice []string)

func ThisLine

func ThisLine() int

func TimeToString

func TimeToString(time time.Time) string

func Trace added in v1.0.1

func Trace(v interface{}, depth int)

func Ucfirst

func Ucfirst(str string) string

func UcfirstArr added in v1.0.1

func UcfirstArr(in []string) (out []string)

func UnionStrings added in v1.0.1

func UnionStrings(src []string, dest []string) []string

UnionString 取两个字符串列表的并集

Types

type AuthEvent added in v1.0.1

type AuthEvent struct {
	Name    string
	Access  bool
	Message string
}

type BusToMany added in v1.0.1

type BusToMany map[string][]Handler

type BusToOne added in v1.0.1

type BusToOne map[string]Handler

type ConsoleLogger

type ConsoleLogger struct {
	Logger *log.Logger
}

文件日志

func NewConsoleLogger

func NewConsoleLogger() *ConsoleLogger

func (*ConsoleLogger) Printf

func (this *ConsoleLogger) Printf(format string, v ...interface{})

type EzChannel

type EzChannel struct {
	Channels map[string]chan int
}

todo 等用的时候再测试补充

func (*EzChannel) Create

func (this *EzChannel) Create(name string)

type EzWaitGroup

type EzWaitGroup struct {
	WaitGroups map[string]*sync.WaitGroup
}
var EzWg *EzWaitGroup

func GetWg

func GetWg() *EzWaitGroup

func (*EzWaitGroup) Add

func (this *EzWaitGroup) Add(name string)

func (*EzWaitGroup) AddInt

func (this *EzWaitGroup) AddInt(name string, delta int)

func (*EzWaitGroup) Clear

func (this *EzWaitGroup) Clear(name string)

func (*EzWaitGroup) CreateWaitGroup

func (this *EzWaitGroup) CreateWaitGroup(name string) *sync.WaitGroup

func (*EzWaitGroup) Done

func (this *EzWaitGroup) Done(name string)

func (*EzWaitGroup) Get

func (this *EzWaitGroup) Get(name string) *sync.WaitGroup

type FileLogger

type FileLogger struct {
	Root     string //./var/
	FilePath string //文件名,默认“/orm.log”

	Logger  *log.Logger
	MaxSize int64 //最大容量,默认2M
	MaxLine int   //最大行数,默认10000
	// contains filtered or unexported fields
}

文件日志

func NewFileLogger

func NewFileLogger() *FileLogger

func (*FileLogger) CreateNewFile

func (this *FileLogger) CreateNewFile() *os.File

func (*FileLogger) Printf

func (this *FileLogger) Printf(format string, v ...interface{})

type FileTool

type FileTool struct {
}

func (FileTool) CreateDirForPath

func (this FileTool) CreateDirForPath(Path string) error

func (FileTool) GetExt

func (this FileTool) GetExt(Path string) string

type FileUpload

type FileUpload struct {
	Name string `json:"name"`
	File string `json:"file"`
}

type Handler added in v1.0.1

type Handler func(v interface{}, ctx context.Context)

type Ids

type Ids struct {
	Ids []int `json:"ids"`
}

多选操作Id数组

func NewIds

func NewIds() *Ids

type IntKeyMap

type IntKeyMap map[int]interface{}

func (IntKeyMap) Len

func (s IntKeyMap) Len() int

func (IntKeyMap) Less

func (s IntKeyMap) Less(i, j int) bool

func (IntKeyMap) Swap

func (s IntKeyMap) Swap(i, j int)

type IntSlice

type IntSlice []int

func (IntSlice) Len

func (s IntSlice) Len() int

func (IntSlice) Less

func (s IntSlice) Less(i, j int) bool

func (IntSlice) Swap

func (s IntSlice) Swap(i, j int)

type Logger

type Logger struct {
	Type string //默认写入文件

	//配置
	//-文件日志
	FilePath string
	//mq日志
	NsqPubAddr string
	Depth      int
	DepthSkip  int
	// contains filtered or unexported fields
}

func CreateLogger

func CreateLogger() *Logger

func (*Logger) InitConsoleLogger

func (this *Logger) InitConsoleLogger()

func (*Logger) InitFileLogger

func (this *Logger) InitFileLogger()

func (*Logger) InitMqLogger

func (this *Logger) InitMqLogger()

func (*Logger) Printf

func (this *Logger) Printf(format string, v ...interface{})

func (*Logger) UseConsoleLogger

func (this *Logger) UseConsoleLogger()

func (*Logger) UseFileLogger

func (this *Logger) UseFileLogger()

func (*Logger) UseMqLogger

func (this *Logger) UseMqLogger()

func (*Logger) UseNoLogger

func (this *Logger) UseNoLogger()

type M

type M map[string]interface{}

func (M) Len

func (s M) Len() int

func (M) Less

func (s M) Less(i, j string) bool

func (*M) String

func (s *M) String() string

func (M) Swap

func (s M) Swap(i, j string)

type MqLogger

type MqLogger struct {
	TopicName  string
	NsqPubAddr string
	// contains filtered or unexported fields
}

文件日志

func NewMqLogger

func NewMqLogger(nsqPubAddr string) *MqLogger

func (*MqLogger) Printf

func (this *MqLogger) Printf(format string, v ...interface{})

type Process

type Process struct {
	Name       string
	Start      int64
	End        int64
	Cost       int64
	CostString string
	Note       string
}

func (*Process) Done

func (this *Process) Done(message ...string)

type Slice

type Slice []interface{}

func (Slice) Len

func (s Slice) Len() int

func (Slice) Less

func (s Slice) Less(i, j int) bool

func (Slice) Swap

func (s Slice) Swap(i, j int)

type StringKeyMap

type StringKeyMap map[string]interface{}

func (StringKeyMap) Len

func (s StringKeyMap) Len() int

func (StringKeyMap) Less

func (s StringKeyMap) Less(i, j string) bool

func (StringKeyMap) Swap

func (s StringKeyMap) Swap(i, j string)

type Timer

type Timer struct {
	Start   int64
	End     int64
	Process []*Process
}

func NewTimer

func NewTimer() *Timer

func (*Timer) Add

func (this *Timer) Add(name string) *Process

func (*Timer) Done

func (this *Timer) Done()

func (*Timer) Report

func (this *Timer) Report()

type YmlConfig added in v1.0.1

type YmlConfig struct {
	FilePath string
}

func (*YmlConfig) FillModel added in v1.0.1

func (this *YmlConfig) FillModel(model interface{})

func (*YmlConfig) SetFilePath added in v1.0.1

func (this *YmlConfig) SetFilePath(path string)

type Zipper

type Zipper struct {
	Path   string
	Name   string
	Target string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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