1- # Go Util
1+ # GoUtil
22
33![ GitHub go.mod Go version] ( https://img.shields.io/github/go-mod/go-version/gookit/goutil?style=flat-square )
44[ ![ GitHub tag (latest SemVer)] ( https://img.shields.io/github/tag/gookit/goutil )] ( https://github.com/gookit/goutil )
@@ -193,7 +193,6 @@ func StringsFilter(ss []string, filter ...comdef.StringMatchFunc) []string
193193func StringsMap(ss []string, mapFn func(s string) string) []string
194194func TrimStrings(ss []string, cutSet ...string) []string
195195```
196-
197196</details>
198197
199198#### ArrUtil Usage
@@ -218,6 +217,7 @@ ss, err := arrutil.ToStrings([]int{1, 2}) // ss: []string{"1", "2"}
218217```
219218
220219
220+
221221### Bytes Utils
222222
223223> Package ` github.com/gookit/goutil/byteutil `
@@ -253,7 +253,6 @@ func NewStdEncoder(encFn BytesEncodeFunc, decFn BytesDecodeFunc) *StdEncoder
253253// source at byteutil/pool.go
254254func NewChanPool(chSize int, width int, capWidth int) *ChanPool
255255```
256-
257256</details>
258257
259258
@@ -263,6 +262,7 @@ func NewChanPool(chSize int, width int, capWidth int) *ChanPool
263262
264263`cflag` - Wraps and extends go `flag.FlagSet` to build simple command line applications
265264
265+
266266<details><summary>Click to see functions 👈</summary>
267267
268268```go
@@ -295,14 +295,14 @@ func IsFlagHelpErr(err error) bool
295295func WrapColorForCode(s string) string
296296func ReplaceShorts(args []string, shortsMap map[string]string) []string
297297```
298-
299298</details>
300299
301300#### `cflag` Usage
302301
303302`cflag` usage please see [cflag/README.md](cflag/README.md)
304303
305304
305+
306306### CLI Utils
307307
308308> Package `github.com/gookit/goutil/cliutil`
@@ -345,7 +345,6 @@ func InputIsYes(ans string) bool
345345func ByteIsYes(ans byte) bool
346346func ReadPassword(question ...string) string
347347```
348-
349348</details>
350349
351350
@@ -404,6 +403,7 @@ Build line: ./myapp -a val0 -m "this is message" arg0
404403
405404> More, please see [ ./cliutil/README] ( cliutil/README.md )
406405
406+
407407### Var Dumper
408408
409409> Package ` github.com/gookit/goutil/dump `
@@ -438,7 +438,6 @@ func WithoutColor() OptionFunc
438438func WithoutType() OptionFunc
439439func WithoutLen() OptionFunc
440440```
441-
442441</details>
443442
444443#### Examples
@@ -485,6 +484,7 @@ Preview:
485484![ ] ( dump/_examples/preview-nested-struct.png )
486485
487486
487+
488488### ENV/Environment
489489
490490> Package ` github.com/gookit/goutil/envutil `
@@ -534,7 +534,6 @@ func UnsetEnvs(keys ...string)
534534func LoadText(text string)
535535func LoadString(line string) bool
536536```
537-
538537</details>
539538
540539#### ENV Util Usage
@@ -556,6 +555,7 @@ envutil.ParseValue("${ENV_NAME | defValue}")
556555```
557556
558557
558+
559559### Errorx
560560
561561> Package `github.com/gookit/goutil/errorx`
@@ -564,6 +564,7 @@ envutil.ParseValue("${ENV_NAME | defValue}")
564564
565565> Additional call stack information is included when printing errors, making it easy to log and find problems.
566566
567+
567568<details><summary>Click to see functions 👈</summary>
568569
569570```go
@@ -615,7 +616,6 @@ func Is(err, target error) bool
615616func To(err error, target any) bool
616617func As(err error, target any) bool
617618```
618-
619619</details>
620620
621621
@@ -695,12 +695,14 @@ runtime.goexit()
695695```
696696
697697
698+
698699### File System
699700
700701> Package `github.com/gookit/goutil/fsutil`
701702
702703Package `fsutil` Filesystem util functions: quick check, create, read and write file. eg: file and dir check, operate
703704
705+
704706<details><summary>Click to see functions 👈</summary>
705707
706708```go
@@ -835,7 +837,6 @@ func MustCopyFile(srcPath, dstPath string)
835837func UpdateContents(filePath string, handleFn func(bs []byte) []byte) error
836838func CreateSymlink(target, linkPath string) error
837839```
838-
839840</details>
840841
841842
@@ -869,6 +870,7 @@ func main() {
869870```
870871
871872
873+
872874### JSON Utils
873875
874876> Package `github.com/gookit/goutil/jsonutil`
@@ -962,7 +964,6 @@ func MakeByKeys(keys []string, val any) (mp map[string]any)
962964func SetByPath(mp *map[string]any, path string, val any) error
963965func SetByKeys(mp *map[string]any, keys []string, val any) (err error)
964966```
965-
966967</details>
967968
968969
@@ -971,6 +972,7 @@ func SetByKeys(mp *map[string]any, keys []string, val any) (err error)
971972> Package `github.com/gookit/goutil/mathutil`
972973
973974Package `mathutil` provide math(int, number) util functions. eg: convert, math calc, random
975+
974976<details><summary>Click to see functions 👈</summary>
975977
976978```go
@@ -1092,7 +1094,6 @@ func RandInt(min, max int) int
10921094func RandIntWithSeed(min, max int, seed int64) int
10931095func RandomIntWithSeed(min, max int, seed int64) int
10941096```
1095-
10961097</details>
10971098
10981099
@@ -1101,6 +1102,7 @@ func RandomIntWithSeed(min, max int, seed int64) int
11011102> Package `github.com/gookit/goutil/reflects`
11021103
11031104Package `reflects` Provide extends reflection util functions. eg: check, convert, value set, etc.
1105+
11041106<details><summary>Click to see functions 👈</summary>
11051107
11061108```go
@@ -1168,7 +1170,6 @@ func SetRValue(rv, val reflect.Value)
11681170func Wrap(rv reflect.Value) Value
11691171func ValueOf(v any) Value
11701172```
1171-
11721173</details>
11731174
11741175
@@ -1177,6 +1178,7 @@ func ValueOf(v any) Value
11771178> Package `github.com/gookit/goutil/structs`
11781179
11791180Package `structs` Provide some extends util functions for struct. eg: tag parse, struct init, value set/get
1181+
11801182<details><summary>Click to see functions 👈</summary>
11811183
11821184```go
@@ -1229,7 +1231,6 @@ func WithBeforeSetFn(fn BeforeSetFunc) SetOptFunc
12291231func BindData(ptr any, data map[string]any, optFns ...SetOptFunc) error
12301232func SetValues(ptr any, data map[string]any, optFns ...SetOptFunc) error
12311233```
1232-
12331234</details>
12341235
12351236
@@ -1507,7 +1508,6 @@ func OrHandle(s string, fn comdef.StringHandleFunc) string
15071508func Valid(ss ...string) string
15081509func SubstrCount(s, substr string, params ...uint64) (int, error)
15091510```
1510-
15111511</details>
15121512
15131513
@@ -1592,7 +1592,6 @@ func ChangeUserByName(newUname string) error
15921592func ChangeUserUidGid(newUID int, newGid int) error
15931593func ChangeUserUIDGid(newUID int, newGid int) (err error)
15941594```
1595-
15961595</details>
15971596
15981597
@@ -1640,7 +1639,6 @@ func RestoreTimeLocal()
16401639func NewTestWriter() *TestWriter
16411640func NewDirEnt(fPath string, isDir ...bool) *fakeobj.DirEntry
16421641```
1643-
16441642</details>
16451643
16461644
@@ -1649,6 +1647,7 @@ func NewDirEnt(fPath string, isDir ...bool) *fakeobj.DirEntry
16491647> Package `github.com/gookit/goutil/timex`
16501648
16511649Provides an enhanced `time.Time` implementation, and add more commonly used functional methods.
1650+
16521651<details><summary>Click to see functions 👈</summary>
16531652
16541653```go
@@ -1714,8 +1713,8 @@ func FormatUnix(sec int64, layout ...string) string
17141713func FormatUnixBy(sec int64, layout string) string
17151714func FormatUnixByTpl(sec int64, template ...string) string
17161715```
1717-
17181716</details>
1717+
17191718#### Timex Usage
17201719
17211720**Create timex instance**
@@ -1835,6 +1834,7 @@ date := FormatUnixByTpl(ts, "Y-m-d H:I:S") // Get: 2022-04-20 19:40:34
18351834```
18361835
18371836
1837+
18381838## Code Check & Testing
18391839
18401840```bash
0 commit comments