Documentation ¶
Index ¶
- Constants
- Variables
- func AddProperty[T Property](p T, properties ...T) T
- func Black(str string) string
- func Blue(str string) string
- func CheckSetDefault(m *map[string]interface{}, key string, value interface{}) bool
- func Clear()
- func ClearIOBuffer()
- func CmdPy(pythonPath string, cmdArgs ...string) (result string, err error)
- func CopyFile(dstName, srcName string) (written int64, err error)
- func CreateDirWhenNotExist(path string) error
- func CreateProperty[T Property](properties ...T) T
- func CutToStrings(str string) []string
- func Cyan(str string) string
- func DeleteFileAndChild(path string) error
- func GetFileContent(path string) string
- func GetGitVersion(repoPath string) (string, error)
- func GetIndexPage(index int, pageSize int, pageBegin1 bool) (page int, pageIndex int)
- func GetIpAddr(Ip string) string
- func GetMaxPage(total int, pageSize int, pageBegin1 bool) (maxPage int)
- func GetNameFromPath(path string) string
- func GetPageIndexOriIndex(index int, page int, pageSize int, pageBegin1 bool) int
- func GetPageStartEnd(page int, pageSize int, total int, pageBegin1 bool) (pageStart int, pageEnd int)
- func GetPicLinkFromStr(mdStr string) []string
- func GetRealDir() string
- func GetTimeStr() string
- func Green(str string) string
- func HasOneProperty[T Property](p T, properties ...T) bool
- func HasProperty[T Property](p T, properties ...T) bool
- func Init(h *ArrayHeap)
- func Input(hint string, len int, a ...interface{}) error
- func InputInt(notice string) int
- func InputStr(len int) string
- func InputString(notice string) string
- func InputStringWithSpace(notice string) []string
- func IsDir(path string) bool
- func IsLegalOutURL(url string) bool
- func JoinErr(errs ...error) error
- func Len(h *ArrayHeap) int
- func MakeEmptyFile(path string, isDir bool) error
- func MarkdownToHTML(md string) string
- func MinMax(array []CanCompare) (min CanCompare, minIndex int, max CanCompare, maxIndex int)
- func MinMaxInt(array []int) (min int, minIndex int, max int, maxIndex int)
- func MinMaxSlice[T cmp.Ordered](array []T) (min T, minIndex int, max T, maxIndex int)
- func MinMaxUInt(array []uint32) (min uint32, minIndex int, max uint32, maxIndex int)
- func MoveFile(srcPath, dstPath string) error
- func PathExist(path string) bool
- func Purple(str string) string
- func Push(h *ArrayHeap, x Comparable)
- func ReadAllDir(root string) []string
- func ReadAllFile(root string) []string
- func ReadGBKFileLine(addr string) (string, error)
- func Red(str string) string
- func ReplaceUnicodeEscapes(input string) string
- func Stop()
- func Str2list(s string) []string
- func White(str string) string
- func WriteGBKFileLine(addr string, content string) error
- func Yellow(str string) string
- type ArrayHeap
- type CanCompare
- type CmdMenu
- type Comparable
- type ErrStr
- type Error
- type FileCore
- func (f *FileCore) Delete() error
- func (f *FileCore) Equal(other FileCore) bool
- func (f *FileCore) GetSize() int64
- func (f *FileCore) MakeChildEmptyFile(name string, isDir bool) error
- func (f *FileCore) Move(newDir string) error
- func (f *FileCore) Rename(newName string) error
- func (f *FileCore) Valid() bool
- type FileNode
- type FileUnit
- type FileUnitType
- type FuncQueueCaller
- type GitCommit
- type GoLimit
- type GoLimitSetting
- type IFileRwUnit
- type ISyncProtoRec
- type ISyncProtoSend
- type InitTag
- type IpApi
- type JsonTool
- type LoadTag
- type LosePicUrlError
- type MarkdownTool
- type Opr
- type OprType
- type Oprs
- type Property
- type SingleMenu
- type StringTag
- type Sync
- type TJsonTool
- type TomlTool
Constants ¶
const ( FileUnitJson = iota FileUnitToml )
const ( ErrCtxNil = ErrStr("ctx is nil") ErrParamInvalid = ErrStr("param invalid") )
const ( ErrStop = ErrStr("stop") ErrNotStart = ErrStr("not start") )
const ( ErrNotInit = ErrStr("not init") ErrRepeatInit = ErrStr("repeat init") )
const (
ErrNil = ErrStr("nil")
)
Variables ¶
var GJsonTool = &JsonTool{}
var GTomlTool = &TomlTool{}
Functions ¶
func AddProperty ¶
func AddProperty[T Property](p T, properties ...T) T
func CheckSetDefault ¶
CheckSetDefault 检查默认值是否存在,若否则置上。返回默认值是否存在
func ClearIOBuffer ¶
func ClearIOBuffer()
func CreateDirWhenNotExist ¶
func CreateProperty ¶
func CreateProperty[T Property](properties ...T) T
func CutToStrings ¶
func DeleteFileAndChild ¶
func GetFileContent ¶
func GetIndexPage ¶
func GetNameFromPath ¶
func GetPageIndexOriIndex ¶
func GetPageStartEnd ¶
func GetPicLinkFromStr ¶
GetPicLinkFromStr 从字符串中提取所有的图片外链
func HasOneProperty ¶
func HasProperty ¶
func InputString ¶
func InputStringWithSpace ¶
func MakeEmptyFile ¶
func MinMax ¶
func MinMax(array []CanCompare) (min CanCompare, minIndex int, max CanCompare, maxIndex int)
MinMax 求一个CanCompare切片的最大最小值
func MinMaxSlice ¶
MinMaxSlice 求一个切片的最大最小值
func MinMaxUInt ¶
MinMaxUInt 求一个int切片的最大最小值
func Push ¶
func Push(h *ArrayHeap, x Comparable)
func ReadAllDir ¶
ReadAllDir 返回root目录下所有的目录,当出现错误时返回nil,否则至少返回空
func ReadAllFile ¶
ReadAllFile 返回root目录下所有的目录,当出现错误时返回nil,否则至少返回空数组
func ReadGBKFileLine ¶
func ReplaceUnicodeEscapes ¶
func WriteGBKFileLine ¶
Types ¶
type ArrayHeap ¶
type ArrayHeap []Comparable
type CanCompare ¶
type CanCompare interface {
Less(CanCompare) bool
}
type CmdMenu ¶
type CmdMenu struct { HisList []*SingleMenu // 方便完成返回到上一步 HisListIndex int // contains filtered or unexported fields }
func (*CmdMenu) Init ¶
func (m *CmdMenu) Init(root *SingleMenu)
type Comparable ¶
type Comparable interface {
Less(other Comparable) bool
}
func Pop ¶
func Pop(h *ArrayHeap) Comparable
func Remove ¶
func Remove(h *ArrayHeap, i int) Comparable
func Top ¶
func Top(h *ArrayHeap) Comparable
type FileCore ¶
type FileCore struct { // 绝对路径 Addr string // ./a/b/a_c.c.txt -> a_c.c.txt Name string // ./a/b/c.txt -> txt Extension string IsDir bool }
FileCore 操作文件,获得文件的基础消息。
func (*FileCore) MakeChildEmptyFile ¶
type FileUnit ¶
type FileUnit[T any] struct { // contains filtered or unexported fields }
FileUnit 是一个可以用于任意类型的非一次性序列化工具 可以将变量的指针与文件中的实际值关联 NewFileUnit 会将结构体绑定某一个文件地址,之后可以通过Load和Save来进行读写
func NewFileUnit ¶
func NewFileUnit[T any](unitType FileUnitType, addr string) *FileUnit[T]
NewFileUnit 初始化文件单元
func (*FileUnit[T]) SafeUseData ¶
SafeUseData 线程安全的使用数据的函数
type FileUnitType ¶
type FileUnitType int
type FuncQueueCaller ¶
type FuncQueueCaller struct {
// contains filtered or unexported fields
}
func (*FuncQueueCaller) Exit ¶
func (q *FuncQueueCaller) Exit() bool
func (*FuncQueueCaller) Init ¶
func (q *FuncQueueCaller) Init(num int, paraNum int)
func (*FuncQueueCaller) PushFunc ¶
func (q *FuncQueueCaller) PushFunc(f func()) bool
type GoLimit ¶
type GoLimit struct { InitTag // contains filtered or unexported fields }
GoLimit 并发执行限流器 如果超过限制上线,会阻塞 如果一个函数跨越两个周期,会阻塞 init 后调用 start使用 停止通过ctx实现或直接调用 不支持stop后重新start
type GoLimitSetting ¶
type GoLimitSetting struct { TimeInterval time.Duration // 每隔多少秒重置一次 EveryIntervalCallNum int32 // 每个周期允许执行多少次 }
GoLimitSetting 并发执行限流器设置
type IFileRwUnit ¶
type ISyncProtoRec ¶
type ISyncProtoSend ¶
type InitTag ¶
type InitTag struct {
Init bool
}
func (*InitTag) IsInitialized ¶
func (*InitTag) SetInitialized ¶
func (receiver *InitTag) SetInitialized()
type IpApi ¶
type IpApi struct { Code int `json:"code"` Msg string `json:"msg"` Ipinfo struct { Type string `json:"type"` Text string `json:"text"` Cnip bool `json:"cnip"` } `json:"ipinfo"` Ipdata struct { Info1 string `json:"info1"` Info2 string `json:"info2"` Info3 string `json:"info3"` Isp string `json:"isp"` } `json:"ipdata"` Adcode struct { O string `json:"o"` P string `json:"p"` C string `json:"c"` N string `json:"n"` R string `json:"r"` A string `json:"a"` I bool `json:"i"` } `json:"adcode"` Tips string `json:"tips"` Time int `json:"time"` }
type LosePicUrlError ¶
type MarkdownTool ¶
type MarkdownTool struct {
// contains filtered or unexported fields
}
func (*MarkdownTool) AddContent ¶
func (m *MarkdownTool) AddContent(content string)
func (*MarkdownTool) AddList ¶
func (m *MarkdownTool) AddList(content string, lv int)
func (*MarkdownTool) AddMd ¶
func (m *MarkdownTool) AddMd(md string)
func (*MarkdownTool) AddReference ¶
func (m *MarkdownTool) AddReference(reference string)
func (*MarkdownTool) AddTitle ¶
func (m *MarkdownTool) AddTitle(title string, lv int)
func (*MarkdownTool) ToStr ¶
func (m *MarkdownTool) ToStr() string
type Oprs ¶
type Oprs struct {
// contains filtered or unexported fields
}
func (*Oprs) AddCreateDir ¶
func (*Oprs) ConfirmAndDo ¶
type SingleMenu ¶
type SingleMenu struct { Name string // 项目名 F func() // 可以被call的节点 SubMenu []*SingleMenu }
type Sync ¶
func (*Sync) OnRecResult ¶
func (s *Sync) OnRecResult(data ISyncProtoRec) error
type TJsonTool ¶
type TJsonTool struct {
// contains filtered or unexported fields
}
TJsonTool 是对于json文件的抽象,可以用匿名组合的方式进行二次包装
请注意已经被废弃,请使用JsonTool与FileUnit
func NewTJsonTool ¶
NewTJsonTool 针对传入的数据初始化,在此时会载入数据。如果传入地址为空则不进行载入 !!!!!!!!当传入值也能正常工作,但是传入指针可以避免浪费了右值,并且可以直接对结构体进行操作!!!!!!!