Documentation ¶
Index ¶
- func ByteCountIEC(b int64) string
- func CatchAsError(err *error)
- func ChainFuncs[P func(H) H, H any](h H, ps ...P) H
- func Delete(fsys fs.FS, name string) error
- func DropLast1[First any, Last any](f First, l Last) First
- func Filter[S []E, E any](s S, predicate func(e E) bool) []E
- func IIF[Any any](cond bool, first, second Any) Any
- func Implements[T any](a any) bool
- func IsEmail(email string) bool
- func IsURL(Url string, addScheme bool) bool
- func JoinInts(ints []int64, delim string) string
- func ListBackupFiles(fsys fs.FS, dir string) ([]*proto.BackupFileSpec, error)
- func ListFiles(fsys fs.FS, dir string) ([]*proto.FileSpec, error)
- func Map[T any, S []E, E any](s S, mapper func(e E) T) []T
- func MemDupReader(r io.Reader) func() io.Reader
- func Must(e error)
- func Must1[A any](a A, e error) A
- func MustToInt64(s string) int64
- func NewDirFSWithNotify(root string) fs.FS
- func NewOverlayFS(layers ...fs.FS) fs.FS
- func RandomString() string
- func ReInitTestRandomSeed()
- func ToInt64(s string) (int64, error)
- func Write(fsys fs.FS, spec *proto.FileSpec, r io.Reader) error
- func WriteFile(fs afero.Fs, path string, mode fs.FileMode, modified time.Time, size int64, ...) error
- type BatchDebouncer
- type Debouncer
- type DeleteFS
- type DirFSWithNotify
- type FsWithChangeNotify
- type Maintenance
- type PluginStorage
- type ServeMuxChain
- type TemplateLoader
- type Throttler
- type WriteFS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CatchAsError ¶
func CatchAsError(err *error)
func IIF ¶
Go 语言多少有点儿大病,以至于我需要写这种东西。 是谁当初说不需要三元运算符的?我打断他的 🐶 腿。 https://en.wikipedia.org/wiki/IIf https://blog.twofei.com/716/#没有条件运算符
func Implements ¶
func ListBackupFiles ¶
Deprecated. 用 ListFiles。
func ListFiles ¶
walk returns the file list for a directory. Directories are omitted. Returned paths are related to dir. 返回的所有路径都是相对于 dir 而言的。
func MemDupReader ¶
基于内存实现的可重复读的 Reader。 https://blog.twofei.com/1072/
func MustToInt64 ¶
func NewDirFSWithNotify ¶
func RandomString ¶
func RandomString() string
func ReInitTestRandomSeed ¶
func ReInitTestRandomSeed()
Types ¶
type BatchDebouncer ¶
type BatchDebouncer[K comparable] struct { // contains filtered or unexported fields }
func NewBatchDebouncer ¶
func NewBatchDebouncer[K comparable](interval time.Duration, fn func(k K)) *BatchDebouncer[K]
func (*BatchDebouncer[K]) Enter ¶
func (b *BatchDebouncer[K]) Enter(k K)
type Debouncer ¶
type Debouncer struct {
// contains filtered or unexported fields
}
func NewDebouncer ¶
防抖神器。
仅在动作稳定一定时间后才执行。
比如:我需要在模板文件更新后刷新模板,但是切分支的时候会有收到大量文件修改通知, 此时不能每收到一个文件就触发一次刷新,需要在“稳定”(分支切换完全后、几秒内没有文件再有修改) 的情况下方可刷新。可避免掉大量无意义的刷新。
NOTE:回调函数 fn 是在独立的线程中被调用的。
type DirFSWithNotify ¶
func (*DirFSWithNotify) Changed ¶
func (l *DirFSWithNotify) Changed() <-chan fsnotify.Event
type FsWithChangeNotify ¶
type Maintenance ¶
type Maintenance struct { Message string Estimated time.Duration // contains filtered or unexported fields }
func NewMaintenance ¶
func NewMaintenance() *Maintenance
func (*Maintenance) EstimatedString ¶
func (m *Maintenance) EstimatedString() string
func (*Maintenance) Leave ¶
func (m *Maintenance) Leave()
func (*Maintenance) MessageString ¶
func (m *Maintenance) MessageString() string
type PluginStorage ¶
type ServeMuxChain ¶
type TemplateLoader ¶
type TemplateLoader struct {
// contains filtered or unexported fields
}
func NewTemplateLoader ¶
func NewTemplateLoader(fsys fs.FS, funcs template.FuncMap, refreshed func()) *TemplateLoader
refreshed: 初次加载不会调用,后面刷新调用。
func (*TemplateLoader) GetPartial ¶
func (l *TemplateLoader) GetPartial(name string) *template.Template
type Throttler ¶
type Throttler[Key comparable] struct { // contains filtered or unexported fields }
func NewThrottler ¶
func NewThrottler[Key comparable]() *Throttler[Key]
节流神器。
仅在动作完成一定时间后才允许再度执行。 基于时间,而不是漏桶🪣或令牌。
比如:十秒钟内只允许评论一次。
Source Files ¶
Click to show internal directories.
Click to hide internal directories.