Skip to content

Commit

Permalink
chore: up readme, re-generate readme docs
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 10, 2022
1 parent 5a8002e commit 8d10730
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 73 deletions.
47 changes: 22 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,7 @@ PRINT AT github.com/gookit/goutil/cliutil_test.TestParseLine(line_parser_test.go
Build line: ./myapp -a val0 -m "this is message" arg0
```

### Common

> Package `github.com/gookit/goutil/common`
```go
```

> More, please see [./cliutil/README](cliutil/README.md)
### Dump

> Package `github.com/gookit/goutil/dump`
Expand Down Expand Up @@ -499,9 +493,6 @@ func ExpandPath(pathStr string) string
func Realpath(pathStr string) string
func GlobWithFunc(pattern string, fn func(filePath string) error) (err error)
func FindInDir(dir string, handleFn HandleFunc, filters ...FilterFunc) (err error)
// source at fsutil/ioutil.go
func QuietWriteString(w io.Writer, ss ...string)
func NewWriteWrapper(w io.Writer) *WriteWrapper
// source at fsutil/operate.go
func Mkdir(dirPath string, perm os.FileMode) error
func MkParentDir(fpath string) error
Expand Down Expand Up @@ -564,7 +555,7 @@ func main() {
}
```
### JSON
### JSON util
> Package `github.com/gookit/goutil/jsonutil`
Expand Down Expand Up @@ -659,13 +650,6 @@ func RandIntWithSeed(min, max int, seed int64) int
func RandomIntWithSeed(min, max int, seed int64) int
```
### Numbers
> Package `github.com/gookit/goutil/numbers`
```go
```
### Reflects
> Package `github.com/gookit/goutil/reflects`
Expand All @@ -680,6 +664,19 @@ func Wrap(rv reflect.Value) Value
func ValueOf(v interface{}) Value
```
### Stdio
> Package `github.com/gookit/goutil/stdio`
```go
// source at stdio/ioutil.go
func QuietWriteString(w io.Writer, ss ...string)
func DiscardReader(src io.Reader)
func MustReadReader(r io.Reader) []byte
// source at stdio/writer.go
func NewWriteWrapper(w io.Writer) *WriteWrapper
```
### Standard
> Package `github.com/gookit/goutil/stdutil`
Expand Down Expand Up @@ -729,7 +726,7 @@ func MustToMap(st interface{}) map[string]interface{}
func ParseTags(v interface{}) error
func ParseReflectTags(v reflect.Value) error
func ParseTagValue(str string) maputil.SMap
func ParseTagValueINI(field, str string) (mp maputil.SMap, err error)
func ParseTagValueINI(field, tagStr string) (mp maputil.SMap, err error)
```
### String
Expand Down Expand Up @@ -878,7 +875,6 @@ func FindExecutable(binName string) (string, error)
func Executable(binName string) (string, error)
func HasExecutable(binName string) bool
// source at sysutil/sysenv.go
func Hostname() string
func IsWin() bool
func IsWindows() bool
func IsMac() bool
Expand All @@ -887,6 +883,7 @@ func IsMSys() bool
func IsConsole(out io.Writer) bool
func IsTerminal(fd uintptr) bool
func StdIsTerminal() bool
func Hostname() string
func CurrentShell(onlyName bool) (path string)
func HasShellEnv(shell string) bool
func IsShellSpecialVar(c uint8) bool
Expand Down Expand Up @@ -1068,16 +1065,16 @@ Template Vars:
Examples, use timex:
```go
now := timex.Now()
date := now.DateFormat("Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
date = now.DateFormat("y-M-D H:i:s") // Output: 22-04-20 19:40:34
tx := timex.Now()
date := tx.DateFormat("Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
date = tx.DateFormat("y-M-D H:i:s") // Output: 22-04-20 19:40:34
```
Format time.Time:
```go
now := time.Now()
date := timex.DateFormat(now, "Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
tx := time.Now()
date := timex.DateFormat(tx, "Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
```
More usage:
Expand Down
51 changes: 24 additions & 27 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
[![Unit-Tests](https://github.com/gookit/goutil/workflows/Unit-Tests/badge.svg)](https://github.com/gookit/goutil/actions)
[![Coverage Status](https://coveralls.io/repos/github/gookit/goutil/badge.svg?branch=master)](https://coveralls.io/github/gookit/goutil?branch=master)

Go一些常用的工具函数收集、实现和整理
Go一些常用的工具函数实现、增强、收集和整理

- [`arrutil`](./arrutil) array/slice 相关操作的函数工具包 如:类型转换,元素检查等等
- `dump` 简单的变量打印工具,打印 slice, map 会自动换行显示每个元素,同时会显示打印调用位置
- `cliutil` CLI 的一些工具函数包. eg: read input, exec command, cmdline parse/build
- [`errorx`](./errorx) 为 go 提供增强的错误实现,允许使用堆栈跟踪和包装另一个错误
- [`errorx`](./errorx) 为 go 提供增强的错误实现,允许带有堆栈跟踪信息和包装另一个错误
- `envutil` ENV 信息获取判断工具包. eg: get one, get info, parse var
- `fmtutil` 格式化数据工具函数
- [`fsutil`](./fsutil) 文件系统操作相关的工具函数包. eg: file and dir check, operate
Expand Down Expand Up @@ -218,13 +218,7 @@ PRINT AT github.com/gookit/goutil/cliutil_test.TestParseLine(line_parser_test.go
Build line: ./myapp -a val0 -m "this is message" arg0
```

### Common

> Package `github.com/gookit/goutil/common`
```go
```

> More, please see [./cliutil/README](cliutil/README.md)
### Dump

> Package `github.com/gookit/goutil/dump`
Expand Down Expand Up @@ -500,9 +494,6 @@ func ExpandPath(pathStr string) string
func Realpath(pathStr string) string
func GlobWithFunc(pattern string, fn func(filePath string) error) (err error)
func FindInDir(dir string, handleFn HandleFunc, filters ...FilterFunc) (err error)
// source at fsutil/ioutil.go
func QuietWriteString(w io.Writer, ss ...string)
func NewWriteWrapper(w io.Writer) *WriteWrapper
// source at fsutil/operate.go
func Mkdir(dirPath string, perm os.FileMode) error
func MkParentDir(fpath string) error
Expand Down Expand Up @@ -565,7 +556,7 @@ func main() {
}
```
### JSON
### JSON util
> Package `github.com/gookit/goutil/jsonutil`
Expand Down Expand Up @@ -660,13 +651,6 @@ func RandIntWithSeed(min, max int, seed int64) int
func RandomIntWithSeed(min, max int, seed int64) int
```
### Numbers
> Package `github.com/gookit/goutil/numbers`
```go
```
### Reflects
> Package `github.com/gookit/goutil/reflects`
Expand All @@ -681,6 +665,19 @@ func Wrap(rv reflect.Value) Value
func ValueOf(v interface{}) Value
```
### Stdio
> Package `github.com/gookit/goutil/stdio`
```go
// source at stdio/ioutil.go
func QuietWriteString(w io.Writer, ss ...string)
func DiscardReader(src io.Reader)
func MustReadReader(r io.Reader) []byte
// source at stdio/writer.go
func NewWriteWrapper(w io.Writer) *WriteWrapper
```
### Standard
> Package `github.com/gookit/goutil/stdutil`
Expand Down Expand Up @@ -730,7 +727,7 @@ func MustToMap(st interface{}) map[string]interface{}
func ParseTags(v interface{}) error
func ParseReflectTags(v reflect.Value) error
func ParseTagValue(str string) maputil.SMap
func ParseTagValueINI(field, str string) (mp maputil.SMap, err error)
func ParseTagValueINI(field, tagStr string) (mp maputil.SMap, err error)
```
### String
Expand Down Expand Up @@ -879,7 +876,6 @@ func FindExecutable(binName string) (string, error)
func Executable(binName string) (string, error)
func HasExecutable(binName string) bool
// source at sysutil/sysenv.go
func Hostname() string
func IsWin() bool
func IsWindows() bool
func IsMac() bool
Expand All @@ -888,6 +884,7 @@ func IsMSys() bool
func IsConsole(out io.Writer) bool
func IsTerminal(fd uintptr) bool
func StdIsTerminal() bool
func Hostname() string
func CurrentShell(onlyName bool) (path string)
func HasShellEnv(shell string) bool
func IsShellSpecialVar(c uint8) bool
Expand Down Expand Up @@ -1069,16 +1066,16 @@ Template Vars:
Examples, use timex:
```go
now := timex.Now()
date := now.DateFormat("Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
date = now.DateFormat("y-M-D H:i:s") // Output: 22-04-20 19:40:34
tx := timex.Now()
date := tx.DateFormat("Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
date = tx.DateFormat("y-M-D H:i:s") // Output: 22-04-20 19:40:34
```
Format time.Time:
```go
now := time.Now()
date := timex.DateFormat(now, "Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
tx := time.Now()
date := timex.DateFormat(tx, "Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
```
More usage:
Expand Down
4 changes: 2 additions & 2 deletions common/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"io"

"github.com/gookit/goutil/fsutil"
"github.com/gookit/goutil/stdio"
)

// DataFormatter interface
Expand Down Expand Up @@ -49,7 +49,7 @@ func (f *BaseFormatter) BsWriter() ByteStringWriter {
} else if ow, ok := f.Out.(ByteStringWriter); ok {
f.ow = ow
} else {
f.ow = fsutil.NewWriteWrapper(f.Out)
f.ow = stdio.NewWriteWrapper(f.Out)
}
}

Expand Down
5 changes: 4 additions & 1 deletion dump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ You will see:

## More preview

- print struct

![](_examples/struct.png)

- nested struct

![](_examples/preview-nested-struct.png)


## Functions

```go
Expand Down
14 changes: 3 additions & 11 deletions internal/gendoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
var (
hidden = []string{
"netutil",
"numutil",
"common",
"numbers",
"internal",
}
nameMap = map[string]string{
Expand All @@ -35,21 +36,12 @@ var (
"test": "testing",
"dump": "dump",
"structs": "struct",
"json": "JSON",
"json": "JSON util",
"cli": "CLI/Console",
"env": "ENV/Environment",
"std": "standard",
}

pkgDesc = map[string]map[string]string{
"en": {
"arr": "Package arrutil provides some util functions for array, slice",
},
"zh-CN": {
"arr": "`arrutil` 包提供一些辅助函数,用于数组、切片处理",
},
}

allowLang = map[string]int{
"en": 1,
"zh-CN": 1,
Expand Down
4 changes: 2 additions & 2 deletions internal/template/README.zh-CN.md.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
[![Unit-Tests](https://github.com/gookit/goutil/workflows/Unit-Tests/badge.svg)](https://github.com/gookit/goutil/actions)
[![Coverage Status](https://coveralls.io/repos/github/gookit/goutil/badge.svg?branch=master)](https://coveralls.io/github/gookit/goutil?branch=master)

Go一些常用的工具函数收集、实现和整理
Go一些常用的工具函数实现、增强、收集和整理

- [`arrutil`](./arrutil) array/slice 相关操作的函数工具包 如:类型转换,元素检查等等
- `dump` 简单的变量打印工具,打印 slice, map 会自动换行显示每个元素,同时会显示打印调用位置
- `cliutil` CLI 的一些工具函数包. eg: read input, exec command, cmdline parse/build
- [`errorx`](./errorx) 为 go 提供增强的错误实现,允许使用堆栈跟踪和包装另一个错误
- [`errorx`](./errorx) 为 go 提供增强的错误实现,允许带有堆栈跟踪信息和包装另一个错误
- `envutil` ENV 信息获取判断工具包. eg: get one, get info, parse var
- `fmtutil` 格式化数据工具函数
- [`fsutil`](./fsutil) 文件系统操作相关的工具函数包. eg: file and dir check, operate
Expand Down
2 changes: 2 additions & 0 deletions internal/template/part-cliutil.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ PRINT AT github.com/gookit/goutil/cliutil_test.TestParseLine(line_parser_test.go
Build line: ./myapp -a val0 -m "this is message" arg0
```

> More, please see [./cliutil/README](cliutil/README.md)
10 changes: 5 additions & 5 deletions internal/template/part-timex.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ Template Vars:
Examples, use timex:

```go
now := timex.Now()
date := now.DateFormat("Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
date = now.DateFormat("y-M-D H:i:s") // Output: 22-04-20 19:40:34
tx := timex.Now()
date := tx.DateFormat("Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
date = tx.DateFormat("y-M-D H:i:s") // Output: 22-04-20 19:40:34
```

Format time.Time:

```go
now := time.Now()
date := timex.DateFormat(now, "Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
tx := time.Now()
date := timex.DateFormat(tx, "Y-M-D H:i:s") // Output: 2022-04-20 19:40:34
```

More usage:
Expand Down

0 comments on commit 8d10730

Please sign in to comment.