Skip to content

Commit

Permalink
👔 up: comdef,str - add some commonly interface and update str, doc logic
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 16, 2023
1 parent 0babcc7 commit 8469c34
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
13 changes: 13 additions & 0 deletions comdef/comdef.go
Expand Up @@ -20,6 +20,19 @@ type StringWriteStringer interface {
fmt.Stringer
}

// StringMatcher interface
type StringMatcher interface {
Match(s string) bool
}

// StringMatchFunc definition
type StringMatchFunc func(s string) bool

// Match satisfies the StringMatcher interface
func (fn StringMatchFunc) Match(s string) bool {
return fn(s)
}

type (
// MarshalFunc define
MarshalFunc func(v any) ([]byte, error)
Expand Down
1 change: 1 addition & 0 deletions internal/gendoc/main.go
Expand Up @@ -22,6 +22,7 @@ import (

var (
hidden = []string{
"basefn",
"netutil",
"comdef",
"internal",
Expand Down
11 changes: 7 additions & 4 deletions internal/template/README.md.tpl
Expand Up @@ -18,7 +18,7 @@
- [`envutil`](./envutil) ENV util for current runtime env information. eg: get one, get info, parse var
- [`fmtutil`](./fmtutil) Format data util functions. eg: data, size, time
- [`fsutil`](./fsutil) Filesystem util functions, quick create, read and write file. eg: file and dir check, operate
- [`jsonutil`](./jsonutil) some util functions for quick read, write, encode, decode JSON data.
- [`jsonutil`](./jsonutil) Provide some util functions for quick read, write, encode, decode JSON data.
- [`maputil`](./maputil) Map data util functions. eg: convert, sub-value get, simple merge
- [`mathutil`](./mathutil) Math(int, number) util functions. eg: convert, math calc, random
- `netutil` Network util functions
Expand All @@ -35,16 +35,19 @@
- [cmdline](./cliutil/cmdline) Provide cmdline parse, args build to cmdline
- [`dump`](./dump): GO value printing tool. print slice, map will auto wrap each element and display the call location
- [`errorx`](./errorx) Provide an enhanced error implements for go, allow with stacktrace and wrap another error.
- [`finder`](./fsutil/finder) Provides a simple and convenient filedir lookup function, supports filtering, excluding, matching, ignoring, etc.
- net util:
- [httpreq](netutil/httpreq) An easier-to-use HTTP client that wraps http.Client
- string util:
- [textscan](strutil/textscan) Implemented a parser that quickly scans and analyzes text content. It can be used to parse INI, Properties and other formats
- sys util:
- [textutil](strutil/textutil) Provide some extensions text handle util functions. eg: text replace, etc.
- system util:
- [clipboard](./sysutil/clipboard) Provide a simple clipboard read and write operations.
- [cmdr](./sysutil/cmdr) Provide for quick build and run a cmd, batch run multi cmd tasks
- [process](./sysutil/process) Provide some process handle util functions.
- [`testutil`](./testutil) Test help util functions. eg: http test, mock ENV value
- [assert](./testutil/assert) Asserts functions for help testing
- [`testutil`](testutil) Test help util functions. eg: http test, mock ENV value
- [assert](testutil/assert) Provides commonly asserts functions for help testing
- [fakeobj](testutil/fakeobj) provides a fake object for testing. such as fake fs.File, fs.FileInfo, fs.DirEntry etc.
- [`timex`](./timex) Provides an enhanced time.Time implementation. Add more commonly used functional methods
- such as: DayStart(), DayAfter(), DayAgo(), DateFormat() and more.

Expand Down
9 changes: 6 additions & 3 deletions internal/template/README.zh-CN.md.tpl
Expand Up @@ -33,16 +33,19 @@
- [`cflag`](./cflag): 包装和扩展 go `flag.FlagSet` 以方便快速的构建简单的命令行应用程序
- [`dump`](./dump) GO变量打印工具,打印 slice, map 会自动换行显示每个元素,同时会显示打印调用位置
- [`errorx`](./errorx) 为 go 提供增强的错误实现,允许带有堆栈跟踪信息和包装另一个错误。
- strutil:
- [`finder`](./fsutil/finder) 提供简单方便的file/dir查找功能,支持过滤、排除、匹配、忽略等。
- netutil:
- `netutil/httpreq` 包装 http.Client 实现的更加易于使用的HTTP客户端
- strutil:
- [textscan](strutil/textscan) 实现了一个快速扫描和分析文本内容的解析器. 可用于解析 INI, Properties 等格式内容
- [textutil](strutil/textutil) 提供一些常用的扩展文本处理功能函数。
- sysutil:
- [clipboard](sysutil/clipboard) 提供简单的剪贴板读写操作工具库
- [cmdr](sysutil/cmdr) 提供快速构建和运行一个cmd,批量运行多个cmd任务
- [process](./sysutil/process) 提供一些进程操作相关的实用功能。
- [process](sysutil/process) 提供一些进程操作相关的实用功能。
- [`testutil`](testutil) test help 相关操作的函数工具包. eg: http test, mock ENV value
- [assert](testutil/assert) 用于帮助测试的断言函数工具包
- [assert](testutil/assert) 用于帮助测试的断言函数工具包,方便编写单元测试。
- [fakeobj](testutil/fakeobj) 提供一些接口的假的实现,用于模拟测试. 例如 fs.File, fs.FileInfo, fs.DirEntry 等等.
- [`timex`](timex) 提供增强的 time.Time 实现。添加更多常用的功能方法
- 提供类似 `Y-m-d H:i:s` 的日期时间格式解析处理
- 例如: DayStart(), DayAfter(), DayAgo(), DateFormat() 等等
Expand Down
5 changes: 4 additions & 1 deletion strutil/filter.go
Expand Up @@ -64,6 +64,9 @@ func FilterEmail(s string) string {
return s
}

// According to rfc5321, "The local-part of a mailbox MUST BE treated as case sensitive"
// According to rfc5321, "The local-part of a mailbox MUST BE treated as case-sensitive"
return s[0:i] + "@" + strings.ToLower(s[i+1:])
}

// func Filter(ss []string, fls ...comdef.StringMatchFunc) []string {
// }
3 changes: 2 additions & 1 deletion strutil/id.go
Expand Up @@ -39,7 +39,8 @@ func MicroTimeHexID() string {

// DatetimeNo generate. can use for order-no.
//
// No prefix, return like: 2023041410484904074285478388(len: 28)
// - No prefix, return like: 2023041410484904074285478388(len: 28)
// - With prefix, return like: prefix2023041410484904074285478388(len: 28 + len(prefix))
func DatetimeNo(prefix string) string {
nt := time.Now()
pl := len(prefix)
Expand Down

0 comments on commit 8469c34

Please sign in to comment.