Skip to content

Commit

Permalink
chore: update toe arr, str, test pkg README
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 16, 2022
1 parent 87c962d commit 7526dca
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
43 changes: 42 additions & 1 deletion arrutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,48 @@ go get github.com/gookit/goutil/arrutil
## Functions API

```go

func AnyToString(arr any) string
func CloneSlice(data any) interface{}
func Contains(arr, val any) bool
func ExceptWhile(data any, fn Predicate) interface{}
func Excepts(first, second any, fn Comparer) interface{}
func Find(source any, fn Predicate) (interface{}, error)
func FindOrDefault(source any, fn Predicate, defaultValue any) interface{}
func FormatIndent(arr any, indent string) string
func GetRandomOne(arr any) interface{}
func HasValue(arr, val any) bool
func InStrings(elem string, ss []string) bool
func Int64sHas(ints []int64, val int64) bool
func Intersects(first any, second any, fn Comparer) interface{}
func IntsHas(ints []int, val int) bool
func JoinSlice(sep string, arr ...any) string
func JoinStrings(sep string, ss ...string) string
func MakeEmptySlice(itemType reflect.Type) interface{}
func MustToInt64s(arr any) []int64
func MustToStrings(arr any) []string
func NotContains(arr, val any) bool
func RandomOne(arr any) interface{}
func Reverse(ss []string)
func SliceToInt64s(arr []any) []int64
func SliceToString(arr ...any) string
func SliceToStrings(arr []any) []string
func StringsFilter(ss []string, filter ...func(s string) bool) []string
func StringsHas(ss []string, val string) bool
func StringsJoin(sep string, ss ...string) string
func StringsMap(ss []string, mapFn func(s string) string) []string
func StringsRemove(ss []string, s string) []string
func StringsToInts(ss []string) (ints []int, err error)
func StringsToSlice(ss []string) []interface{}
func TakeWhile(data any, fn Predicate) interface{}
func ToInt64s(arr any) (ret []int64, err error)
func ToString(arr []any) string
func ToStrings(arr any) (ret []string, err error)
func TrimStrings(ss []string, cutSet ...string) []string
func TwowaySearch(data any, item any, fn Comparer) (int, error)
func Union(first, second any, fn Comparer) interface{}
func Unique(arr any) interface{}
type ArrFormatter struct{ ... }
func NewFormatter(arr any) *ArrFormatter
```

## Code Check & Testing
Expand Down
19 changes: 19 additions & 0 deletions strutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,22 @@ func VersionCompare(v1, v2, op string) bool
func WidthWrap(s string, w int) string
func WrapTag(s, tag string) string
```

## Code Check & Testing

```bash
gofmt -w -l ./
golint ./...
```

**Testing**:

```shell
go test -v ./strutil/...
```

**Test limit by regexp**:

```shell
go test -v -run ^TestSetByKeys ./strutil/...
```
25 changes: 25 additions & 0 deletions testutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@ func TestNewTestWriter(t *testing.T) {
}
```

## Functions API

```go
func ClearOSEnv()
func DiscardStdout() error
func MockCleanOsEnv(mp map[string]string, fn func())
func MockEnvValue(key, val string, fn func(nv string))
func MockEnvValues(kvMap map[string]string, fn func())
func MockOsEnv(mp map[string]string, fn func())
func MockOsEnvByText(envText string, fn func())
func MockRequest(h http.Handler, method, path string, data *MD) *httptest.ResponseRecorder
func NewHttpRequest(method, path string, data *MD) *http.Request
func RestoreStderr(printData ...bool) (s string)
func RestoreStdout(printData ...bool) (s string)
func RevertOSEnv()
func RewriteStderr()
func RewriteStdout()
type Buffer struct{ ... }
func NewBuffer() *Buffer
type M map[string]string
type MD struct{ ... }
type TestWriter struct{ ... }
func NewTestWriter() *TestWriter
```

## Code Check & Testing

```bash
Expand Down

0 comments on commit 7526dca

Please sign in to comment.