Skip to content

Commit

Permalink
✅ fix: fix go import error and re-generate docs
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Mar 26, 2023
1 parent 9e8a660 commit 049780e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
19 changes: 14 additions & 5 deletions README.md
Expand Up @@ -7,7 +7,7 @@
[![Coverage Status](https://coveralls.io/repos/github/gookit/goutil/badge.svg?branch=master)](https://coveralls.io/github/gookit/goutil?branch=master)
[![Go Reference](https://pkg.go.dev/badge/github.com/gookit/goutil.svg)](https://pkg.go.dev/github.com/gookit/goutil)

💪 Useful utils(**500+**) package for the Go: int, string, array/slice, map, error, time, format, CLI, ENV, filesystem, system, testing and more.
💪 Useful utils(**600+**) package for the Go: int, string, array/slice, map, error, time, format, CLI, ENV, filesystem, system, testing and more.

> **[中文说明](README.zh-CN.md)**
Expand Down Expand Up @@ -692,6 +692,7 @@ func TempDir(dir, pattern string) (string, error)
func MimeType(path string) (mime string)
func ReaderMimeType(r io.Reader) (mime string)
func JoinPaths(elem ...string) string
func JoinSubPaths(basePath string, elem ...string) string
func SlashPath(path string) string
func UnixPath(path string) string
func ToAbsPath(p string) string
Expand Down Expand Up @@ -793,6 +794,7 @@ func main() {
```go
// source at jsonutil/jsonutil.go
func WriteFile(filePath string, data any) error
func WritePretty(filePath string, data any) error
func ReadFile(filePath string, v any) error
func Pretty(v any) (string, error)
func Encode(v any) ([]byte, error)
Expand All @@ -818,6 +820,7 @@ func HasAllKeys(mp any, keys ...any) (ok bool, noKey any)
func KeyToLower(src map[string]string) map[string]string
func ToStringMap(src map[string]any) map[string]string
func CombineToSMap(keys, values []string) SMap
func ToAnyMap(mp any) map[string]any
func HTTPQueryString(data map[string]any) string
func ToString(mp map[string]any) string
func ToString2(mp any) string
Expand All @@ -832,6 +835,7 @@ func QuietGet(mp map[string]any, path string) (val any)
func GetByPath(path string, mp map[string]any) (val any, ok bool)
func Keys(mp any) (keys []string)
func Values(mp any) (values []any)
func EachAnyMap(mp any, fn func(key string, val any))
// source at maputil/maputil.go
func SimpleMerge(src, dst map[string]any) map[string]any
func DeepMerge(src, dst map[string]any, deep int) map[string]any
Expand Down Expand Up @@ -886,7 +890,9 @@ func QuietString(val any) string
func String(val any) string
func TryToString(val any, defaultAsErr bool) (str string, err error)
// source at mathutil/mathutil.go
func Min[T comdef.XintOrFloat](x, y T) T
func Max[T comdef.XintOrFloat](x, y T) T
func SwapMin[T comdef.XintOrFloat](x, y T) (T, T)
func SwapMax[T comdef.XintOrFloat](x, y T) (T, T)
func MaxInt(x, y int) int
func SwapMaxInt(x, y int) (int, int)
Expand Down Expand Up @@ -938,6 +944,8 @@ func Indirect(v reflect.Value) reflect.Value
func Len(v reflect.Value) int
func SliceSubKind(typ reflect.Type) reflect.Kind
func SetValue(rv reflect.Value, val any) error
func EachMap(mp reflect.Value, fn func(key, val reflect.Value))
func EachStrAnyMap(mp reflect.Value, fn func(key string, val any))
func FlatMap(rv reflect.Value, fn FlatFunc)
// source at reflects/value.go
func Wrap(rv reflect.Value) Value
Expand Down Expand Up @@ -1221,6 +1229,7 @@ func RuneWidth(r rune) int
func TextWidth(s string) int
func Utf8Width(s string) int
func RunesWidth(rs []rune) (w int)
func Truncate(s string, w int, tail string) string
func TextTruncate(s string, w int, tail string) string
func Utf8Truncate(s string, w int, tail string) string
func TextSplit(s string, w int) []string
Expand Down Expand Up @@ -1299,16 +1308,16 @@ func BinFile() string
func Open(fileOrUrl string) error
func OpenBrowser(fileOrUrl string) error
func OpenFile(path string) error
// source at sysutil/sysutil_linux.go
// source at sysutil/sysutil_nonwin.go
func Kill(pid int, signal syscall.Signal) error
func ProcessExists(pid int) bool
// source at sysutil/sysutil_unix.go
func IsWin() bool
func IsWindows() bool
func IsMac() bool
func IsDarwin() bool
func IsLinux() bool
func OpenURL(URL string) error
// source at sysutil/sysutil_nonwin.go
func Kill(pid int, signal syscall.Signal) error
func ProcessExists(pid int) bool
// source at sysutil/user.go
func MustFindUser(uname string) *user.User
func LoginUser() *user.User
Expand Down
19 changes: 14 additions & 5 deletions README.zh-CN.md
Expand Up @@ -7,7 +7,7 @@
[![Coverage Status](https://coveralls.io/repos/github/gookit/goutil/badge.svg?branch=master)](https://coveralls.io/github/gookit/goutil?branch=master)
[![Go Reference](https://pkg.go.dev/badge/github.com/gookit/goutil.svg)](https://pkg.go.dev/github.com/gookit/goutil)

`goutil` Go 常用功能的扩展工具库(**500+**)。包含:数字,byte, 字符串,slice/数组,Map,结构体,反射,文本,文件,错误,时间日期,测试,特殊处理,格式化,常用信息获取等等。
`goutil` Go 常用功能的扩展工具库(**600+**)。包含:数字,byte, 字符串,slice/数组,Map,结构体,反射,文本,文件,错误,时间日期,测试,特殊处理,格式化,常用信息获取等等。

> **[EN README](README.md)**
Expand Down Expand Up @@ -693,6 +693,7 @@ func TempDir(dir, pattern string) (string, error)
func MimeType(path string) (mime string)
func ReaderMimeType(r io.Reader) (mime string)
func JoinPaths(elem ...string) string
func JoinSubPaths(basePath string, elem ...string) string
func SlashPath(path string) string
func UnixPath(path string) string
func ToAbsPath(p string) string
Expand Down Expand Up @@ -794,6 +795,7 @@ func main() {
```go
// source at jsonutil/jsonutil.go
func WriteFile(filePath string, data any) error
func WritePretty(filePath string, data any) error
func ReadFile(filePath string, v any) error
func Pretty(v any) (string, error)
func Encode(v any) ([]byte, error)
Expand All @@ -819,6 +821,7 @@ func HasAllKeys(mp any, keys ...any) (ok bool, noKey any)
func KeyToLower(src map[string]string) map[string]string
func ToStringMap(src map[string]any) map[string]string
func CombineToSMap(keys, values []string) SMap
func ToAnyMap(mp any) map[string]any
func HTTPQueryString(data map[string]any) string
func ToString(mp map[string]any) string
func ToString2(mp any) string
Expand All @@ -833,6 +836,7 @@ func QuietGet(mp map[string]any, path string) (val any)
func GetByPath(path string, mp map[string]any) (val any, ok bool)
func Keys(mp any) (keys []string)
func Values(mp any) (values []any)
func EachAnyMap(mp any, fn func(key string, val any))
// source at maputil/maputil.go
func SimpleMerge(src, dst map[string]any) map[string]any
func DeepMerge(src, dst map[string]any, deep int) map[string]any
Expand Down Expand Up @@ -887,7 +891,9 @@ func QuietString(val any) string
func String(val any) string
func TryToString(val any, defaultAsErr bool) (str string, err error)
// source at mathutil/mathutil.go
func Min[T comdef.XintOrFloat](x, y T) T
func Max[T comdef.XintOrFloat](x, y T) T
func SwapMin[T comdef.XintOrFloat](x, y T) (T, T)
func SwapMax[T comdef.XintOrFloat](x, y T) (T, T)
func MaxInt(x, y int) int
func SwapMaxInt(x, y int) (int, int)
Expand Down Expand Up @@ -939,6 +945,8 @@ func Indirect(v reflect.Value) reflect.Value
func Len(v reflect.Value) int
func SliceSubKind(typ reflect.Type) reflect.Kind
func SetValue(rv reflect.Value, val any) error
func EachMap(mp reflect.Value, fn func(key, val reflect.Value))
func EachStrAnyMap(mp reflect.Value, fn func(key string, val any))
func FlatMap(rv reflect.Value, fn FlatFunc)
// source at reflects/value.go
func Wrap(rv reflect.Value) Value
Expand Down Expand Up @@ -1222,6 +1230,7 @@ func RuneWidth(r rune) int
func TextWidth(s string) int
func Utf8Width(s string) int
func RunesWidth(rs []rune) (w int)
func Truncate(s string, w int, tail string) string
func TextTruncate(s string, w int, tail string) string
func Utf8Truncate(s string, w int, tail string) string
func TextSplit(s string, w int) []string
Expand Down Expand Up @@ -1300,16 +1309,16 @@ func BinFile() string
func Open(fileOrUrl string) error
func OpenBrowser(fileOrUrl string) error
func OpenFile(path string) error
// source at sysutil/sysutil_linux.go
// source at sysutil/sysutil_nonwin.go
func Kill(pid int, signal syscall.Signal) error
func ProcessExists(pid int) bool
// source at sysutil/sysutil_unix.go
func IsWin() bool
func IsWindows() bool
func IsMac() bool
func IsDarwin() bool
func IsLinux() bool
func OpenURL(URL string) error
// source at sysutil/sysutil_nonwin.go
func Kill(pid int, signal syscall.Signal) error
func ProcessExists(pid int) bool
// source at sysutil/user.go
func MustFindUser(uname string) *user.User
func LoginUser() *user.User
Expand Down
3 changes: 1 addition & 2 deletions fsutil/info_nonwin.go
Expand Up @@ -6,15 +6,14 @@ import (
"path"

"github.com/gookit/goutil/internal/comfunc"
"github.com/gookit/goutil/sysutil"
)

// Realpath returns the shortest path name equivalent to path by purely lexical processing.
func Realpath(pathStr string) string {
pathStr = comfunc.ExpandHome(pathStr)

if !IsAbsPath(pathStr) {
pathStr = JoinSubPaths(sysutil.Workdir(), pathStr)
pathStr = JoinSubPaths(comfunc.Workdir(), pathStr)
}
return path.Clean(pathStr)
}
3 changes: 1 addition & 2 deletions fsutil/info_windows.go
Expand Up @@ -2,15 +2,14 @@ package fsutil

import (
"github.com/gookit/goutil/internal/comfunc"
"github.com/gookit/goutil/sysutil"
)

// Realpath returns the shortest path name equivalent to path by purely lexical processing.
func Realpath(pathStr string) string {
pathStr = comfunc.ExpandHome(pathStr)

if !IsAbsPath(pathStr) {
pathStr = JoinSubPaths(sysutil.Workdir(), pathStr)
pathStr = JoinSubPaths(comfunc.Workdir(), pathStr)
}
return filepath.Clean(pathStr)

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.18 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.18 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.18 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.18 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.18 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.18 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.19 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.19 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.19 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.19 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.19 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.19 and windows-latest

undefined: filepath

Check failure on line 14 in fsutil/info_windows.go

View workflow job for this annotation

GitHub Actions / Test on go 1.20 and windows-latest

undefined: filepath
}
6 changes: 6 additions & 0 deletions internal/comfunc/sysfunc.go
Expand Up @@ -8,6 +8,12 @@ import (
"strings"
)

// Workdir get
func Workdir() string {
dir, _ := os.Getwd()
return dir
}

// ExpandHome will parse first `~` as user home dir path.
func ExpandHome(pathStr string) string {
if len(pathStr) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/template/README.md.tpl
Expand Up @@ -7,7 +7,7 @@
[![Coverage Status](https://coveralls.io/repos/github/gookit/goutil/badge.svg?branch=master)](https://coveralls.io/github/gookit/goutil?branch=master)
[![Go Reference](https://pkg.go.dev/badge/github.com/gookit/goutil.svg)](https://pkg.go.dev/github.com/gookit/goutil)

💪 Useful utils(**500+**) package for the Go: int, string, array/slice, map, error, time, format, CLI, ENV, filesystem, system, testing and more.
💪 Useful utils(**600+**) package for the Go: int, string, array/slice, map, error, time, format, CLI, ENV, filesystem, system, testing and more.

> **[中文说明](README.zh-CN.md)**

Expand Down
2 changes: 1 addition & 1 deletion internal/template/README.zh-CN.md.tpl
Expand Up @@ -7,7 +7,7 @@
[![Coverage Status](https://coveralls.io/repos/github/gookit/goutil/badge.svg?branch=master)](https://coveralls.io/github/gookit/goutil?branch=master)
[![Go Reference](https://pkg.go.dev/badge/github.com/gookit/goutil.svg)](https://pkg.go.dev/github.com/gookit/goutil)

`goutil` Go 常用功能的扩展工具库(**500+**)。包含:数字,byte, 字符串,slice/数组,Map,结构体,反射,文本,文件,错误,时间日期,测试,特殊处理,格式化,常用信息获取等等。
`goutil` Go 常用功能的扩展工具库(**600+**)。包含:数字,byte, 字符串,slice/数组,Map,结构体,反射,文本,文件,错误,时间日期,测试,特殊处理,格式化,常用信息获取等等。

> **[EN README](README.md)**

Expand Down

0 comments on commit 049780e

Please sign in to comment.