From 1f849efe1cda9b3206c504be44ccc4f5b7d2bf97 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Fri, 25 Aug 2023 14:31:49 +0800 Subject: [PATCH] doc: update doc for datetime fileutil formatter function package --- docs/.vitepress/en.ts | 9 +- docs/.vitepress/zh.ts | 9 +- .../packages/datetime.md} | 86 ++++++++++--------- .../packages/fileutil.md} | 52 +++++------ .../packages/formatter.md} | 16 ++-- .../packages/function.md} | 30 ++++--- docs/{olddocs => en/api/packages}/datetime.md | 86 ++++++++++--------- docs/{olddocs => en/api/packages}/fileutil.md | 52 +++++------ .../{olddocs => en/api/packages}/formatter.md | 16 ++-- docs/{olddocs => en/api/packages}/function.md | 22 ++--- 10 files changed, 203 insertions(+), 175 deletions(-) rename docs/{olddocs/datetime_zh-CN.md => api/packages/datetime.md} (84%) rename docs/{olddocs/fileutil_zh-CN.md => api/packages/fileutil.md} (84%) rename docs/{olddocs/formatter_zh-CN.md => api/packages/formatter.md} (88%) rename docs/{olddocs/function_zh-CN.md => api/packages/function.md} (85%) rename docs/{olddocs => en/api/packages}/datetime.md (85%) rename docs/{olddocs => en/api/packages}/fileutil.md (84%) rename docs/{olddocs => en/api/packages}/formatter.md (89%) rename docs/{olddocs => en/api/packages}/function.md (87%) diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index b5d911c..3402875 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -43,6 +43,7 @@ export const enConfig: LocaleSpecificConfig = { '/en/': [ { text: 'Introduction', + collapsed: false, items: [ { text: 'What is Lancet?', @@ -62,6 +63,7 @@ export const enConfig: LocaleSpecificConfig = { }, { text: 'packages', + collapsed: false, items: [ { text: 'algorithm', link: '/en/api/packages/algorithm' }, { text: 'compare', link: '/en/api/packages/compare' }, @@ -71,6 +73,7 @@ export const enConfig: LocaleSpecificConfig = { { text: 'cryptor', link: '/en/api/packages/cryptor' }, { text: 'datastructure', + collapsed: true, items: [ { text: 'list', link: '/en/api/packages/datastructure/list' }, { text: 'safelist', link: '/en/api/packages/datastructure/copyonwritelist' }, @@ -81,8 +84,12 @@ export const enConfig: LocaleSpecificConfig = { { text: 'tree', link: '/en/api/packages/datastructure/tree' }, { text: 'set', link: '/en/api/packages/datastructure/set' }, { text: 'hashmap', link: '/en/api/packages/datastructure/hashmap' }, - ] + ], }, + { text: 'datetime', link: '/en/api/packages/datetime' }, + { text: 'fileutil', link: '/en/api/packages/fileutil' }, + { text: 'formatter', link: '/en/api/packages/formatter' }, + { text: 'function', link: '/en/api/packages/function' }, ], }, ], diff --git a/docs/.vitepress/zh.ts b/docs/.vitepress/zh.ts index 4f2f833..4fdcf0d 100644 --- a/docs/.vitepress/zh.ts +++ b/docs/.vitepress/zh.ts @@ -52,6 +52,7 @@ export const zhConfig: LocaleSpecificConfig = { '/': [ { text: '介绍', + collapsed: true, items: [ { text: 'Lancet是什么?', @@ -72,6 +73,7 @@ export const zhConfig: LocaleSpecificConfig = { }, { text: 'API文档', + collapsed: false, items: [ { text: '算法', link: '/api/packages/algorithm' }, { text: '比较器', link: '/api/packages/compare' }, @@ -81,6 +83,7 @@ export const zhConfig: LocaleSpecificConfig = { { text: '加密&解密', link: '/api/packages/cryptor' }, { text: '数据结构', + collapsed: true, items: [ { text: '线性表', link: '/api/packages/datastructure/list' }, { text: '线性表(线程安全)', link: '/api/packages/datastructure/copyonwritelist' }, @@ -91,8 +94,12 @@ export const zhConfig: LocaleSpecificConfig = { { text: '树', link: '/api/packages/datastructure/tree' }, { text: '集合', link: '/api/packages/datastructure/set' }, { text: 'HashMap', link: '/api/packages/datastructure/hashmap' }, - ] + ], }, + { text: '日期&时间', link: '/api/packages/datetime' }, + { text: '文件', link: '/api/packages/fileutil' }, + { text: '格式化工具', link: '/api/packages/formatter' }, + { text: '函数', link: '/api/packages/function' }, ], }, ], diff --git a/docs/olddocs/datetime_zh-CN.md b/docs/api/packages/datetime.md similarity index 84% rename from docs/olddocs/datetime_zh-CN.md rename to docs/api/packages/datetime.md index 93c4519..51c9392 100644 --- a/docs/olddocs/datetime_zh-CN.md +++ b/docs/api/packages/datetime.md @@ -67,6 +67,8 @@ import (
+ + ## 文档 ## 注: @@ -106,7 +108,7 @@ import ( func AddDay(t time.Time, day int64) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/dIGbs_uTdFa) ```go package main @@ -145,7 +147,7 @@ func main() { func AddHour(t time.Time, hour int64) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/rcMjd7OCsi5) ```go package main @@ -184,7 +186,7 @@ func main() { func AddMinute(t time.Time, minute int64) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/nT1heB1KUUK) ```go package main @@ -223,7 +225,7 @@ func main() { func AddYear(t time.Time, year int64) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/MqW2ujnBx10) ```go package main @@ -262,7 +264,7 @@ func main() { func BeginOfMinute(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/ieOLVJ9CiFT) ```go package main @@ -294,7 +296,7 @@ func main() { func BeginOfHour(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/GhdGFnDWpYs) ```go package main @@ -326,7 +328,7 @@ func main() { func BeginOfDay(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/94m_UT6cWs9) ```go package main @@ -358,7 +360,7 @@ func main() { func BeginOfWeek(t time.Time, beginFrom ...time.Weekday) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/ynjoJPz7VNV) ```go package main @@ -390,7 +392,7 @@ func main() { func BeginOfMonth(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/bWXVFsmmzwL) ```go package main @@ -422,7 +424,7 @@ func main() { func BeginOfYear(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/i326DSwLnV8) ```go package main @@ -454,7 +456,7 @@ func main() { func EndOfMinute(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/yrL5wGzPj4z) ```go package main @@ -486,7 +488,7 @@ func main() { func EndOfHour(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/6ce3j_6cVqN) ```go package main @@ -518,7 +520,7 @@ func main() { func EndOfDay(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/eMBOvmq5Ih1) ```go package main @@ -550,7 +552,7 @@ func main() { func EndOfWeek(t time.Time, endWith ...time.Weekday) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/i08qKXD9flf) ```go package main @@ -582,7 +584,7 @@ func main() { func EndOfMonth(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/_GWh10B3Nqi) ```go package main @@ -614,7 +616,7 @@ func main() { func EndOfYear(t time.Time) time.Time ``` -示例: +示例:[运行](https://go.dev/play/p/G01cKlMCvNm) ```go package main @@ -646,7 +648,7 @@ func main() { func GetNowDate() string ``` -示例: +示例:[运行](https://go.dev/play/p/PvfkPpcpBBf) ```go package main @@ -675,7 +677,7 @@ func main() { func GetNowTime() string ``` -示例: +示例:[运行](https://go.dev/play/p/l7BNxCkTmJS) ```go package main @@ -704,7 +706,7 @@ func main() { func GetNowDateTime() string ``` -示例: +示例:[运行](https://go.dev/play/p/pI4AqngD0al) ```go package main @@ -733,7 +735,7 @@ func main() { func GetTodayStartTime() string ``` -示例: +示例:[运行](https://go.dev/play/p/84siyYF7t99) ```go package main @@ -762,7 +764,7 @@ func main() { func GetTodayEndTime() string ``` -示例: +示例:[运行](https://go.dev/play/p/jjrLnfoqgn3) ```go package main @@ -791,7 +793,7 @@ func main() { func GetZeroHourTimestamp() int64 ``` -示例: +示例:[运行](https://go.dev/play/p/QmL2oIaGE3q) ```go package main @@ -820,7 +822,7 @@ func main() { func GetNightTimestamp() int64 ``` -示例: +示例:[运行](https://go.dev/play/p/UolysR3MYP1) ```go package main @@ -849,7 +851,7 @@ func main() { func FormatTimeToStr(t time.Time, format string, timezone ...string) string ``` -示例: +示例:[运行](https://go.dev/play/p/_Ia7M8H_OvE) ```go package main @@ -888,7 +890,7 @@ func main() { func FormatStrToTime(str, format string, timezone ...string) (time.Time, error) ``` -示例: +示例:[运行](https://go.dev/play/p/1h9FwdU8ql4) ```go package main @@ -927,7 +929,7 @@ type theTime struct { func NewUnixNow() *theTime ``` -示例: +示例:[运行](https://go.dev/play/p/U4PPx-9D0oz) ```go package main @@ -959,7 +961,7 @@ type theTime struct { func NewUnix(unix int64) *theTime ``` -示例: +示例:[运行](https://go.dev/play/p/psoSuh_kLRt) ```go package main @@ -991,7 +993,7 @@ type theTime struct { func NewFormat(t string) (*theTime, error) ``` -示例: +示例:[运行](https://go.dev/play/p/VkW08ZOaXPZ) ```go package main @@ -1023,7 +1025,7 @@ type theTime struct { func NewISO8601(iso8601 string) (*theTime, error) ``` -示例: +示例:[运行](https://go.dev/play/p/mkhOHQkdeA2) ```go package main @@ -1052,7 +1054,7 @@ func main() { func (t *theTime) ToUnix() int64 ``` -示例: +示例:[运行](https://go.dev/play/p/_LUiwAdocjy) ```go package main @@ -1081,7 +1083,7 @@ func main() { func (t *theTime) ToFormat() string ``` -示例: +示例:[运行](https://go.dev/play/p/VkW08ZOaXPZ) ```go package main @@ -1110,7 +1112,7 @@ func main() { func (t *theTime) ToFormatForTpl(tpl string) string ``` -示例: +示例:[运行](https://go.dev/play/p/nyXxXcQJ8L5) ```go package main @@ -1140,7 +1142,7 @@ func main() { func (t *theTime) ToIso8601() string ``` -示例: +示例:[运行](https://go.dev/play/p/mkhOHQkdeA2) ```go package main @@ -1170,7 +1172,7 @@ func main() { func IsLeapYear(year int) bool ``` -示例: +示例:[运行](https://go.dev/play/p/xS1eS2ejGew) ```go package main @@ -1203,7 +1205,7 @@ func main() { func BetweenSeconds(t1 time.Time, t2 time.Time) int64 ``` -示例: +示例:[运行](https://go.dev/play/p/n3YDRyfyXJu) ```go package main @@ -1240,7 +1242,7 @@ func main() { func DayOfYear(t time.Time) int ``` -示例: +示例:[运行](https://go.dev/play/p/0hjqhTwFNlH) ```go package main @@ -1281,7 +1283,7 @@ func main() { func IsWeekend(t time.Time) bool ``` -示例: +示例:[运行](https://go.dev/play/p/cupRM5aZOIY) ```go package main @@ -1321,7 +1323,7 @@ func main() { func NowDateOrTime(format string, timezone ...string) string ``` -实例: +示例:[运行](https://go.dev/play/p/EZ-begEjtT0) ```go package main @@ -1355,7 +1357,7 @@ func main() { func Timestamp(timezone ...string) int64 ``` -实例: +示例:[运行](https://go.dev/play/p/iU5b7Vvjx6x) ```go package main @@ -1386,7 +1388,7 @@ func main() { func TimestampMilli(timezone ...string) int64 ``` -实例: +示例:[运行](https://go.dev/play/p/4gvEusOTu1T) ```go package main @@ -1416,7 +1418,7 @@ func main() { func TimestampMicro(timezone ...string) int64 ``` -实例: +示例:[运行](https://go.dev/play/p/2maANglKHQE) ```go package main @@ -1446,7 +1448,7 @@ func main() { func TimestampNano(timezone ...string) int64 ``` -实例: +示例:[运行](https://go.dev/play/p/A9Oq_COrcCF) ```go package main diff --git a/docs/olddocs/fileutil_zh-CN.md b/docs/api/packages/fileutil.md similarity index 84% rename from docs/olddocs/fileutil_zh-CN.md rename to docs/api/packages/fileutil.md index 57f6f8c..6e95162 100644 --- a/docs/olddocs/fileutil_zh-CN.md +++ b/docs/api/packages/fileutil.md @@ -50,6 +50,8 @@ import (
+ + ## 文档 ### ClearFile @@ -62,7 +64,7 @@ import ( func ClearFile(path string) error ``` -示例: +示例:[运行](https://go.dev/play/p/NRZ0ZT-G94H) ```go package main @@ -90,7 +92,7 @@ func main() { func CreateFile(path string) bool ``` -示例: +示例:[运行](https://go.dev/play/p/lDt8PEsTNKI) ```go package main @@ -116,7 +118,7 @@ func main() { func CreateDir(absPath string) error ``` -示例: +示例:[运行](https://go.dev/play/p/qUuCe1OGQnM) ```go package main @@ -142,7 +144,7 @@ func main() { func CopyFile(srcPath string, dstPath string) error ``` -示例: +示例:[运行](https://go.dev/play/p/Jg9AMJMLrJi) ```go package main @@ -170,7 +172,7 @@ func main() { func CurrentPath() string ``` -示例: +示例:[运行](https://go.dev/play/p/s74a9iBGcSw) ```go package main @@ -196,7 +198,7 @@ func main() { func FileMode(path string) (fs.FileMode, error) ``` -示例: +示例:[运行](https://go.dev/play/p/2l2hI42fA3p) ```go package main @@ -225,7 +227,7 @@ func main() { func MiMeType(file any) string ``` -示例: +示例:[运行](https://go.dev/play/p/bd5sevSUZNu) ```go package main @@ -256,7 +258,7 @@ func main() { func IsExist(path string) bool ``` -示例: +示例:[运行](https://go.dev/play/p/nKKXt8ZQbmh) ```go package main @@ -283,7 +285,7 @@ func main() { func IsLink(path string) bool ``` -示例: +示例:[运行](https://go.dev/play/p/TL-b-Kzvf44) ```go package main @@ -309,7 +311,7 @@ func main() { func IsDir(path string) bool ``` -示例: +示例:[运行](https://go.dev/play/p/WkVwEKqtOWk) ```go package main @@ -338,7 +340,7 @@ func main() { func ListFileNames(path string) ([]string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/Tjd7Y07rejl) ```go package main @@ -364,7 +366,7 @@ func main() { func RemoveFile(path string) error ``` -示例: +示例:[运行](https://go.dev/play/p/P2y0XW8a1SH) ```go package main @@ -392,7 +394,7 @@ func main() { func ReadFileToString(path string) (string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/cmfwp_5SQTp) ```go package main @@ -425,7 +427,7 @@ func main() { func ReadFileByLine(path string)([]string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/svJP_7ZrBrD) ```go package main @@ -459,7 +461,7 @@ func main() { func Zip(fpath string, destPath string) error ``` -示例: +示例:[运行](https://go.dev/play/p/j-3sWBp8ik_P) ```go package main @@ -487,7 +489,7 @@ func main() { func ZipAppendEntry(fpath string, destPath string) error ``` -示例: +示例:[运行](https://go.dev/play/p/cxvaT8TRNQp) ```go package main @@ -515,7 +517,7 @@ func main() { func UnZip(zipFile string, destPath string) error ``` -示例: +示例:[运行](https://go.dev/play/p/g0w34kS7B8m) ```go package main @@ -543,7 +545,7 @@ func main() { func IsZipFile(filepath string) bool ``` -示例: +示例:[运行](https://go.dev/play/p/9M0g2j_uF_e) ```go package main @@ -569,7 +571,7 @@ func main() { func FileSize(path string) (int64, error) ``` -示例: +示例:[运行](https://go.dev/play/p/H9Z05uD-Jjc) ```go package main @@ -601,7 +603,7 @@ func main() { func MTime(filepath string) (int64, error) ``` -示例: +示例:[运行](https://go.dev/play/p/s_Tl7lZoAaY) ```go package main @@ -633,7 +635,7 @@ func main() { func Sha(filepath string, shaType ...int) (string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/VfEEcO2MJYf) ```go package main @@ -671,7 +673,7 @@ func main() { func ReadCsvFile(filepath string) ([][]string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/OExTkhGEd3_u) ```go package main @@ -703,7 +705,7 @@ func main() { func WriteCsvFile(filepath string, records [][]string, append bool) error ``` -示例: +示例:[运行](https://go.dev/play/p/dAXm58Q5U1o) ```go package main @@ -752,7 +754,7 @@ func main() { func WriteBytesToFile(filepath string, content []byte) error ``` -示例: +示例:[运行](https://go.dev/play/p/s7QlDxMj3P8) ```go package main @@ -801,7 +803,7 @@ func main() { func WriteStringToFile(filepath string, content string, append bool) error ``` -示例: +示例:[运行](https://go.dev/play/p/GhLS6d8lH_g) ```go package main diff --git a/docs/olddocs/formatter_zh-CN.md b/docs/api/packages/formatter.md similarity index 88% rename from docs/olddocs/formatter_zh-CN.md rename to docs/api/packages/formatter.md index ab29ae2..202d645 100644 --- a/docs/olddocs/formatter_zh-CN.md +++ b/docs/api/packages/formatter.md @@ -33,6 +33,8 @@ import (
+ + ## 文档 ### Comma @@ -45,7 +47,7 @@ import ( func Comma[T constraints.Float | constraints.Integer | string](value T, symbol string) string ``` -示例: +示例:[运行](https://go.dev/play/p/eRD5k2vzUVX) ```go package main @@ -81,7 +83,7 @@ func main() { func Pretty(v any) (string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/YsciGj3FH2x) ```go package main @@ -120,7 +122,7 @@ func main() { func PrettyToWriter(v any, out io.Writer) error ``` -示例: +示例:[运行](https://go.dev/play/p/LPLZ3lDi5ma) ```go package main @@ -163,7 +165,7 @@ func main() { func DecimalBytes(size float64, precision ...int) string ``` -示例: +示例:[运行](https://go.dev/play/p/FPXs1suwRcs) ```go package main @@ -202,7 +204,7 @@ func main() { func BinaryBytes(size float64, precision ...int) string ``` -示例: +示例:[运行](https://go.dev/play/p/G9oHHMCAZxP) ```go package main @@ -241,7 +243,7 @@ func main() { func ParseDecimalBytes(size string) (uint64, error) ``` -示例: +示例:[运行](https://go.dev/play/p/Am98ybWjvjj) ```go package main @@ -280,7 +282,7 @@ func main() { func ParseBinaryBytes(size string) (uint64, error) ``` -示例: +示例:[运行](https://go.dev/play/p/69v1tTT62x8) ```go package main diff --git a/docs/olddocs/function_zh-CN.md b/docs/api/packages/function.md similarity index 85% rename from docs/olddocs/function_zh-CN.md rename to docs/api/packages/function.md index ca1c953..186bb79 100644 --- a/docs/olddocs/function_zh-CN.md +++ b/docs/api/packages/function.md @@ -37,6 +37,8 @@ import ( ## 文档 + + ### After

创建一个函数,当他被调用n或更多次之后将马上触发fn

@@ -47,7 +49,7 @@ import ( func After(n int, fn any) func(args ...any) []reflect.Value ``` -示例: +示例:[运行](https://go.dev/play/p/eRD5k2vzUVX) ```go package main @@ -80,7 +82,7 @@ func main() { func Before(n int, fn any) func(args ...any) []reflect.Value ``` -示例: +示例:[运行](https://go.dev/play/p/0HqUDIFZ3IL) ```go package main @@ -88,7 +90,6 @@ package main import ( "fmt" "github.com/duke-git/lancet/v2/function" - "github.com/duke-git/lancet/v2/internal" ) func main() { @@ -118,7 +119,7 @@ type CurryFn[T any] func(...T) T func (cf CurryFn[T]) New(val T) func(...T) T ``` -示例: +示例:[运行](https://go.dev/play/p/5HopfDwANKX) ```go package main @@ -157,7 +158,7 @@ func main() { func Compose[T any](fnList ...func(...T) T) func(...T) T ``` -示例: +示例:[运行](https://go.dev/play/p/KKfugD4PKYF) ```go package main @@ -195,7 +196,7 @@ func main() { func Debounced(fn func(), duration time.Duration) func() ``` -示例: +示例:[运行](https://go.dev/play/p/absuEGB_GN7) ```go package main @@ -245,7 +246,7 @@ func main() { func Delay(delay time.Duration, fn any, args ...any) ``` -示例: +示例:[运行](https://go.dev/play/p/Ivtc2ZE-Tye) ```go package main @@ -277,7 +278,7 @@ func main() { func Schedule(d time.Duration, fn any, args ...any) chan bool ``` -示例: +示例:[运行](https://go.dev/play/p/hbON-Xeyn5N) ```go package main @@ -316,7 +317,7 @@ func main() { func Pipeline[T any](funcs ...func(T) T) func(T) T ``` -示例: +示例:[运行](https://go.dev/play/p/mPdUVvj6HD6) ```go package main @@ -361,13 +362,14 @@ type Watcher struct { excuting bool } func NewWatcher() *Watcher -func (w *Watcher) Start() //start the watcher -func (w *Watcher) Stop() //stop the watcher -func (w *Watcher) Reset() //reset the watcher -func (w *Watcher) GetElapsedTime() time.Duration //get the elapsed time of function execution +func (w *Watcher) Start() +func (w *Watcher) Stop() +func (w *Watcher) Reset() +func (w *Watcher) GetElapsedTime() time.Duration + ``` -示例: +示例:[运行](https://go.dev/play/p/l2yrOpCLd1I) ```go package main diff --git a/docs/olddocs/datetime.md b/docs/en/api/packages/datetime.md similarity index 85% rename from docs/olddocs/datetime.md rename to docs/en/api/packages/datetime.md index 438dacc..12143bc 100644 --- a/docs/olddocs/datetime.md +++ b/docs/en/api/packages/datetime.md @@ -68,6 +68,8 @@ import (
+ + ## Documentation ## Note: @@ -107,7 +109,7 @@ import ( func AddDay(t time.Time, day int64) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/dIGbs_uTdFa) ```go package main @@ -146,7 +148,7 @@ func main() { func AddHour(t time.Time, hour int64) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/rcMjd7OCsi5) ```go package main @@ -185,7 +187,7 @@ func main() { func AddMinute(t time.Time, minute int64) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/nT1heB1KUUK) ```go package main @@ -224,7 +226,7 @@ func main() { func AddYear(t time.Time, year int64) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/MqW2ujnBx10) ```go package main @@ -263,7 +265,7 @@ func main() { func BeginOfMinute(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/ieOLVJ9CiFT) ```go package main @@ -295,7 +297,7 @@ func main() { func BeginOfHour(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/GhdGFnDWpYs) ```go package main @@ -327,7 +329,7 @@ func main() { func BeginOfDay(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/94m_UT6cWs9) ```go package main @@ -359,7 +361,7 @@ func main() { func BeginOfWeek(t time.Time, beginFrom ...time.Weekday) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/ynjoJPz7VNV) ```go package main @@ -391,7 +393,7 @@ func main() { func BeginOfMonth(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/bWXVFsmmzwL) ```go package main @@ -423,7 +425,7 @@ func main() { func BeginOfYear(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/i326DSwLnV8) ```go package main @@ -455,7 +457,7 @@ func main() { func EndOfMinute(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/yrL5wGzPj4z) ```go package main @@ -487,7 +489,7 @@ func main() { func EndOfHour(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/6ce3j_6cVqN) ```go package main @@ -519,7 +521,7 @@ func main() { func EndOfDay(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/eMBOvmq5Ih1) ```go package main @@ -551,7 +553,7 @@ func main() { func EndOfWeek(t time.Time, endWith ...time.Weekday) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/i08qKXD9flf) ```go package main @@ -583,7 +585,7 @@ func main() { func EndOfMonth(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/_GWh10B3Nqi) ```go package main @@ -615,7 +617,7 @@ func main() { func EndOfYear(t time.Time) time.Time ``` -Example: +Example:[Run](https://go.dev/play/p/G01cKlMCvNm) ```go package main @@ -647,7 +649,7 @@ func main() { func GetNowDate() string ``` -Example: +Example:[Run](https://go.dev/play/p/PvfkPpcpBBf) ```go package main @@ -676,7 +678,7 @@ func main() { func GetNowTime() string ``` -Example: +Example:[Run](https://go.dev/play/p/l7BNxCkTmJS) ```go package main @@ -705,7 +707,7 @@ func main() { func GetNowDateTime() string ``` -Example: +Example:[Run](https://go.dev/play/p/pI4AqngD0al) ```go package main @@ -734,7 +736,7 @@ func main() { func GetTodayStartTime() string ``` -Example: +Example:[Run](https://go.dev/play/p/84siyYF7t99) ```go package main @@ -763,7 +765,7 @@ func main() { func GetTodayEndTime() string ``` -Example: +Example:[Run](https://go.dev/play/p/jjrLnfoqgn3) ```go package main @@ -792,7 +794,7 @@ func main() { func GetZeroHourTimestamp() int64 ``` -Example: +Example:[Run](https://go.dev/play/p/QmL2oIaGE3q) ```go package main @@ -821,7 +823,7 @@ func main() { func GetNightTimestamp() int64 ``` -Example: +Example:[Run](https://go.dev/play/p/UolysR3MYP1) ```go package main @@ -850,7 +852,7 @@ func main() { func FormatTimeToStr(t time.Time, format string, timezone ...string) string ``` -Example: +Example:[Run](https://go.dev/play/p/_Ia7M8H_OvE) ```go package main @@ -889,7 +891,7 @@ func main() { func FormatStrToTime(str, format string, timezone ...string) (time.Time, error) ``` -Example: +Example:[Run](https://go.dev/play/p/1h9FwdU8ql4) ```go package main @@ -928,7 +930,7 @@ type theTime struct { func NewUnixNow() *theTime ``` -Example: +Example:[Run](https://go.dev/play/p/U4PPx-9D0oz) ```go package main @@ -960,7 +962,7 @@ type theTime struct { func NewUnix(unix int64) *theTime ``` -Example: +Example:[Run](https://go.dev/play/p/psoSuh_kLRt) ```go package main @@ -992,7 +994,7 @@ type theTime struct { func NewFormat(t string) (*theTime, error) ``` -Example: +Example:[Run](https://go.dev/play/p/VkW08ZOaXPZ) ```go package main @@ -1024,7 +1026,7 @@ type theTime struct { func NewISO8601(iso8601 string) (*theTime, error) ``` -Example: +Example:[Run](https://go.dev/play/p/mkhOHQkdeA2) ```go package main @@ -1053,7 +1055,7 @@ func main() { func (t *theTime) ToUnix() int64 ``` -Example: +Example:[Run](https://go.dev/play/p/_LUiwAdocjy) ```go package main @@ -1082,7 +1084,7 @@ func main() { func (t *theTime) ToFormat() string ``` -Example: +Example:[Run](https://go.dev/play/p/VkW08ZOaXPZ) ```go package main @@ -1111,7 +1113,7 @@ func main() { func (t *theTime) ToFormatForTpl(tpl string) string ``` -Example: +Example:[Run](https://go.dev/play/p/nyXxXcQJ8L5) ```go package main @@ -1141,7 +1143,7 @@ func main() { func (t *theTime) ToIso8601() string ``` -Example: +Example:[Run](https://go.dev/play/p/mkhOHQkdeA2) ```go package main @@ -1171,7 +1173,7 @@ func main() { func IsLeapYear(year int) bool ``` -Example: +Example:[Run](https://go.dev/play/p/xS1eS2ejGew) ```go package main @@ -1204,7 +1206,7 @@ func main() { func BetweenSeconds(t1 time.Time, t2 time.Time) int64 ``` -Example: +Example:[Run](https://go.dev/play/p/n3YDRyfyXJu) ```go package main @@ -1241,7 +1243,7 @@ func main() { func DayOfYear(t time.Time) int ``` -Example: +Example:[Run](https://go.dev/play/p/0hjqhTwFNlH) ```go package main @@ -1282,7 +1284,7 @@ func main() { func IsWeekend(t time.Time) bool ``` -Example: +Example:[Run](https://go.dev/play/p/cupRM5aZOIY) ```go package main @@ -1322,7 +1324,7 @@ func main() { func NowDateOrTime(format string, timezone ...string) string ``` -Example: +Example:[Run](https://go.dev/play/p/EZ-begEjtT0) ```go package main @@ -1356,7 +1358,7 @@ func main() { func Timestamp(timezone ...string) int64 ``` -Example: +Example:[Run](https://go.dev/play/p/iU5b7Vvjx6x) ```go package main @@ -1387,7 +1389,7 @@ func main() { func TimestampMilli(timezone ...string) int64 ``` -Example: +Example:[Run](https://go.dev/play/p/4gvEusOTu1T) ```go package main @@ -1417,7 +1419,7 @@ func main() { func TimestampMicro(timezone ...string) int64 ``` -Example: +Example:[Run](https://go.dev/play/p/2maANglKHQE) ```go package main @@ -1447,7 +1449,7 @@ func main() { func TimestampNano(timezone ...string) int64 ``` -Example: +Example:[Run](https://go.dev/play/p/A9Oq_COrcCF) ```go package main diff --git a/docs/olddocs/fileutil.md b/docs/en/api/packages/fileutil.md similarity index 84% rename from docs/olddocs/fileutil.md rename to docs/en/api/packages/fileutil.md index 4025ecd..e995d16 100644 --- a/docs/olddocs/fileutil.md +++ b/docs/en/api/packages/fileutil.md @@ -50,6 +50,8 @@ import (
+ + ## Documentation ### ClearFile @@ -62,7 +64,7 @@ import ( func ClearFile(path string) error ``` -Example: +Example:[Run](https://go.dev/play/p/NRZ0ZT-G94H) ```go package main @@ -90,7 +92,7 @@ func main() { func CreateFile(path string) bool ``` -Example: +Example:[Run](https://go.dev/play/p/lDt8PEsTNKI) ```go package main @@ -116,7 +118,7 @@ func main() { func CreateDir(absPath string) error ``` -Example: +Example:[Run](https://go.dev/play/p/qUuCe1OGQnM) ```go package main @@ -142,7 +144,7 @@ func main() { func CopyFile(srcPath string, dstPath string) error ``` -Example: +Example:[Run](https://go.dev/play/p/Jg9AMJMLrJi) ```go package main @@ -170,7 +172,7 @@ func main() { func CurrentPath() string ``` -Example: +Example:[Run](https://go.dev/play/p/s74a9iBGcSw) ```go package main @@ -196,7 +198,7 @@ func main() { func FileMode(path string) (fs.FileMode, error) ``` -Example: +Example:[Run](https://go.dev/play/p/2l2hI42fA3p) ```go package main @@ -225,7 +227,7 @@ func main() { func MiMeType(file any) string ``` -Example: +Example:[Run](https://go.dev/play/p/bd5sevSUZNu) ```go package main @@ -256,7 +258,7 @@ func main() { func IsExist(path string) bool ``` -Example: +Example:[Run](https://go.dev/play/p/nKKXt8ZQbmh) ```go package main @@ -283,7 +285,7 @@ func main() { func IsLink(path string) bool ``` -Example: +Example:[Run](https://go.dev/play/p/TL-b-Kzvf44) ```go package main @@ -309,7 +311,7 @@ func main() { func IsDir(path string) bool ``` -Example: +Example:[Run](https://go.dev/play/p/WkVwEKqtOWk) ```go package main @@ -338,7 +340,7 @@ func main() { func ListFileNames(path string) ([]string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/Tjd7Y07rejl) ```go package main @@ -364,7 +366,7 @@ func main() { func RemoveFile(path string) error ``` -Example: +Example:[Run](https://go.dev/play/p/P2y0XW8a1SH) ```go package main @@ -392,7 +394,7 @@ func main() { func ReadFileToString(path string) (string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/cmfwp_5SQTp) ```go package main @@ -425,7 +427,7 @@ func main() { func ReadFileByLine(path string)([]string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/svJP_7ZrBrD) ```go package main @@ -459,7 +461,7 @@ func main() { func Zip(fpath string, destPath string) error ``` -Example: +Example:[Run](https://go.dev/play/p/j-3sWBp8ik_P) ```go package main @@ -487,7 +489,7 @@ func main() { func ZipAppendEntry(fpath string, destPath string) error ``` -Example: +Example:[Run](https://go.dev/play/p/cxvaT8TRNQp) ```go package main @@ -515,7 +517,7 @@ func main() { func UnZip(zipFile string, destPath string) error ``` -Example: +Example:[Run](https://go.dev/play/p/g0w34kS7B8m) ```go package main @@ -543,7 +545,7 @@ func main() { func IsZipFile(filepath string) bool ``` -Example: +Example:[Run](https://go.dev/play/p/9M0g2j_uF_e) ```go package main @@ -569,7 +571,7 @@ func main() { func FileSize(path string) (int64, error) ``` -Example: +Example:[Run](https://go.dev/play/p/H9Z05uD-Jjc) ```go package main @@ -601,7 +603,7 @@ func main() { func MTime(filepath string) (int64, error) ``` -Example: +Example:[Run](https://go.dev/play/p/s_Tl7lZoAaY) ```go package main @@ -633,7 +635,7 @@ func main() { func Sha(filepath string, shaType ...int) (string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/VfEEcO2MJYf) ```go package main @@ -671,7 +673,7 @@ func main() { func ReadCsvFile(filepath string) ([][]string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/OExTkhGEd3_u) ```go package main @@ -703,7 +705,7 @@ func main() { func WriteCsvFile(filepath string, records [][]string, append bool) error ``` -Example: +Example:[Run](https://go.dev/play/p/dAXm58Q5U1o) ```go package main @@ -752,7 +754,7 @@ func main() { func WriteBytesToFile(filepath string, content []byte) error ``` -Example: +Example:[Run](https://go.dev/play/p/s7QlDxMj3P8) ```go package main @@ -801,7 +803,7 @@ func main() { func WriteStringToFile(filepath string, content string, append bool) error ``` -Example: +Example:[Run](https://go.dev/play/p/GhLS6d8lH_g) ```go package main diff --git a/docs/olddocs/formatter.md b/docs/en/api/packages/formatter.md similarity index 89% rename from docs/olddocs/formatter.md rename to docs/en/api/packages/formatter.md index 84104fb..783e57c 100644 --- a/docs/olddocs/formatter.md +++ b/docs/en/api/packages/formatter.md @@ -33,6 +33,8 @@ import (
+ + ## Documentation ### Comma @@ -45,7 +47,7 @@ import ( func Comma[T constraints.Float | constraints.Integer | string](value T, symbol string) string ``` -Example: +Example:[Run](https://go.dev/play/p/eRD5k2vzUVX) ```go package main @@ -81,7 +83,7 @@ func main() { func Pretty(v any) (string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/YsciGj3FH2x) ```go package main @@ -120,7 +122,7 @@ func main() { func PrettyToWriter(v any, out io.Writer) error ``` -Example: +Example:[Run](https://go.dev/play/p/LPLZ3lDi5ma) ```go package main @@ -163,7 +165,7 @@ func main() { func DecimalBytes(size float64, precision ...int) string ``` -Example: +Example:[Run](https://go.dev/play/p/FPXs1suwRcs) ```go package main @@ -202,7 +204,7 @@ func main() { func BinaryBytes(size float64, precision ...int) string ``` -Example: +Example:[Run](https://go.dev/play/p/G9oHHMCAZxP) ```go package main @@ -241,7 +243,7 @@ func main() { func ParseDecimalBytes(size string) (uint64, error) ``` -Example: +Example:[Run](https://go.dev/play/p/Am98ybWjvjj) ```go package main @@ -280,7 +282,7 @@ func main() { func ParseBinaryBytes(size string) (uint64, error) ``` -Example: +Example:[Run](https://go.dev/play/p/69v1tTT62x8) ```go package main diff --git a/docs/olddocs/function.md b/docs/en/api/packages/function.md similarity index 87% rename from docs/olddocs/function.md rename to docs/en/api/packages/function.md index 8d26cbe..5565890 100644 --- a/docs/olddocs/function.md +++ b/docs/en/api/packages/function.md @@ -35,6 +35,7 @@ import (
+ ## Documentation ### After @@ -47,7 +48,7 @@ import ( func After(n int, fn any) func(args ...any) []reflect.Value ``` -Example: +Example:[Run](https://go.dev/play/p/eRD5k2vzUVX) ```go package main @@ -80,7 +81,7 @@ func main() { func Before(n int, fn any) func(args ...any) []reflect.Value ``` -Example: +Example:[Run](https://go.dev/play/p/0HqUDIFZ3IL) ```go package main @@ -88,7 +89,6 @@ package main import ( "fmt" "github.com/duke-git/lancet/v2/function" - "github.com/duke-git/lancet/v2/internal" ) func main() { @@ -118,7 +118,7 @@ type CurryFn[T any] func(...T) T func (cf CurryFn[T]) New(val T) func(...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/5HopfDwANKX) ```go package main @@ -157,7 +157,7 @@ func main() { func Compose[T any](fnList ...func(...T) T) func(...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/KKfugD4PKYF) ```go package main @@ -195,7 +195,7 @@ func main() { func Debounced(fn func(), duration time.Duration) func() ``` -Example: +Example:[Run](https://go.dev/play/p/absuEGB_GN7) ```go package main @@ -245,7 +245,7 @@ func main() { func Delay(delay time.Duration, fn any, args ...any) ``` -Example: +Example:[Run](https://go.dev/play/p/Ivtc2ZE-Tye) ```go package main @@ -277,7 +277,7 @@ func main() { func Schedule(d time.Duration, fn any, args ...any) chan bool ``` -Example: +Example:[Run](https://go.dev/play/p/hbON-Xeyn5N) ```go package main @@ -317,7 +317,7 @@ the functions one by one.

func Pipeline[T any](funcs ...func(T) T) func(T) T ``` -Example: +Example:[Run](https://go.dev/play/p/mPdUVvj6HD6) ```go package main @@ -368,7 +368,7 @@ func (w *Watcher) Reset() //reset the watcher func (w *Watcher) GetElapsedTime() time.Duration //get the elapsed time of function execution ``` -Example: +Example:[Run](https://go.dev/play/p/l2yrOpCLd1I) ```go package main @@ -379,7 +379,7 @@ import ( ) func main() { - w := function.NewWatcher() + w := function.NewWatcher() w.Start()