diff --git a/README.md b/README.md index 40ac016d4..22cd6255e 100644 --- a/README.md +++ b/README.md @@ -945,6 +945,7 @@ func MaxFloat(x, y float64) float64 // source at mathutil/convert.go func NewConvOption[T any](optFns ...ConvOptionFn[T]) *ConvOption[T] func WithNilAsFail[T any](opt *ConvOption[T]) +func WithHandlePtr[T any](opt *ConvOption[T]) func WithUserConvFn[T any](fn ToTypeFunc[T]) ConvOptionFn[T] func Int(in any) (int, error) func SafeInt(in any) int diff --git a/README.zh-CN.md b/README.zh-CN.md index ac56e0398..aca933bed 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -946,6 +946,7 @@ func MaxFloat(x, y float64) float64 // source at mathutil/convert.go func NewConvOption[T any](optFns ...ConvOptionFn[T]) *ConvOption[T] func WithNilAsFail[T any](opt *ConvOption[T]) +func WithHandlePtr[T any](opt *ConvOption[T]) func WithUserConvFn[T any](fn ToTypeFunc[T]) ConvOptionFn[T] func Int(in any) (int, error) func SafeInt(in any) int diff --git a/fsutil/opwrite.go b/fsutil/opwrite.go index 64e3a1bac..09fd2fcfd 100644 --- a/fsutil/opwrite.go +++ b/fsutil/opwrite.go @@ -57,7 +57,8 @@ func TempDir(dir, pattern string) (string, error) { // MustSave create file and write contents to file, panic on error. // -// data type allow: string, []byte, io.Reader +// - data type allow: string, []byte, io.Reader +// // default option see NewOpenOption() func MustSave(filePath string, data any, optFns ...OpenOptionFunc) { basefn.MustOK(SaveFile(filePath, data, optFns...)) @@ -65,6 +66,8 @@ func MustSave(filePath string, data any, optFns ...OpenOptionFunc) { // SaveFile create file and write contents to file. will auto create dir. // +// - data type allow: string, []byte, io.Reader +// // default option see NewOpenOption() func SaveFile(filePath string, data any, optFns ...OpenOptionFunc) error { opt := NewOpenOption(optFns...) diff --git a/reflects/reflects.go b/reflects/reflects.go index cd2ea0eb5..0a6cdde8a 100644 --- a/reflects/reflects.go +++ b/reflects/reflects.go @@ -2,7 +2,6 @@ package reflects import ( - "fmt" "reflect" ) @@ -12,6 +11,6 @@ var ( anyType = reflect.TypeOf((*any)(nil)).Elem() errorType = reflect.TypeOf((*error)(nil)).Elem() - fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() + // fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() reflectValueType = reflect.TypeOf((*reflect.Value)(nil)).Elem() ) diff --git a/strutil/strutil.go b/strutil/strutil.go index 176ef8a47..7a2ca434b 100644 --- a/strutil/strutil.go +++ b/strutil/strutil.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "strings" - "text/template" "github.com/gookit/goutil/comdef" ) @@ -90,22 +89,6 @@ func NewReplacer(pairs map[string]string) *strings.Replacer { return strings.NewReplacer(ss...) } -var builtInFuncs = template.FuncMap{ - // don't escape content - "raw": func(s string) string { - return s - }, - "trim": strings.TrimSpace, - // join strings - "join": func(ss []string, sep string) string { - return strings.Join(ss, sep) - }, - // lower first char - "lcFirst": LowerFirst, - // upper first char - "upFirst": UpperFirst, -} - // WrapTag for given string. func WrapTag(s, tag string) string { if s == "" {