Documentation
¶
Overview ¶
Package tool 常用的python标准库方法实现
Index ¶
- Variables
- func All(args ...bool) bool
- func Any(args ...bool) bool
- func Base64Decode(data string) ([]byte, error)
- func Base64Encode(data []byte) string
- func CombineStrings(elems ...string) string
- func Has[T comparable](s []T, x T) bool
- func HexBeautify(src []byte) string
- func In[T comparable](s []T, x T) bool
- func Index[T comparable](s []T, x T) int
- func IsEqual[T comparable](a, b []T) bool
- func MapToString(object map[string]any) string
- func Max[T types.Ordered](p ...T) T
- func Min[T types.Ordered](p ...T) T
- func Repr(object any, excludeName ...bool) (message string)
- func Reverse[T any](s *[]T)
- func WordCapitalize(word string) string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MarshalJSON = json.Marshal UnmarshalJSON = json.Unmarshal MarshalJSONIndent = json.MarshalIndent NewJSONDecoder = json.NewDecoder NewJSONEncoder = json.NewEncoder // JSONFast 更快的配置,浮点数仅能保留6位小数, 且不能序列化HTML JSONFast = jsoniter.ConfigFastest FastMarshalJSON = JSONFast.Marshal FastUnmarshalJSON = JSONFast.Unmarshal // JSON 默认配置 JSON = JSONFast Marshal = JSON.Marshal Unmarshal = JSON.Unmarshal )
View Source
var ( F = CombineStrings StringsJoin = CombineStrings )
Functions ¶
func CombineStrings ¶
CombineStrings 合并字符串, 实现等同于strings.Join(),只是少了判断分隔符
func Has ¶
func Has[T comparable](s []T, x T) bool
Has 查找序列s内是否存在元素x
@param s []T 查找序列 @param x T 特定元素 @return bool true if s contains x, false otherwise
func In ¶
func In[T comparable](s []T, x T) bool
In 查找序列s内是否存在元素x
@param s []T 查找序列 @param x T 特定元素 @return bool true if s contains x, false otherwise
func IsEqual ¶
func IsEqual[T comparable](a, b []T) bool
IsEqual 判断2个切片是否相等
@return true if is equal
func Repr ¶
Repr 格式化显示对象 将任意对象输出为字符串格式,内部对struct,map,array,string,error实现了string的格式化转换
number -> number
bool -> "true" or "false"
array -> "0d 56 f6";
map -> json;
struct -> StructName({json});
error -> error.Error();
@param object any 需要格式化显示的对象
@param excludeName bool 不显示对象名称, 针对struct有效
@return string ObjectName(...)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.