Documentation
¶
Overview ¶
包utils提供了一些内部使用的工具函数。 md5:7bf96340b2779144
Index ¶
- Variables
- func CanCallIsNil(v interface{}) bool
- func EqualFoldWithoutChars(s1, s2 string) bool
- func FormatCmdKey(s string) string
- func FormatEnvKey(s string) string
- func IsArray(value interface{}) bool
- func IsDebugEnabled() bool
- func IsEmpty(value interface{}) bool
- func IsFloat(value interface{}) bool
- func IsInt(value interface{}) bool
- func IsLetter(b byte) bool
- func IsLetterLower(b byte) bool
- func IsLetterUpper(b byte) bool
- func IsMap(value interface{}) bool
- func IsNil(value interface{}) bool
- func IsNumeric(s string) bool
- func IsSlice(value interface{}) bool
- func IsStruct(value interface{}) bool
- func IsUint(value interface{}) bool
- func ListToMapByKey(list []map[string]interface{}, key string) map[string]interface{}
- func MapContainsPossibleKey(data map[string]interface{}, key string) bool
- func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{})
- func NewReadCloser(content []byte, repeatable bool) io.ReadCloser
- func RemoveSymbols(s string) string
- func ReplaceByMap(origin string, replaces map[string]string) string
- func SetDebugEnabled(enabled bool)
- func SplitAndTrim(str, delimiter string, characterMask ...string) []string
- func StripSlashes(str string) string
- func Trim(str string, characterMask ...string) string
- func UcFirst(s string) string
- type ReadCloser
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTrimChars 是Trim*函数默认删除的字符。 md5:4841fe294d977402 DefaultTrimChars = string([]byte{ '\t', '\v', '\n', '\r', '\f', ' ', 0x00, 0x85, 0xA0, }) )
Functions ¶
func CanCallIsNil ¶
func CanCallIsNil(v interface{}) bool
CanCallIsNil 可以检查 reflect.Value 是否可以安全地调用 reflect.Value.IsNil。 它可以防止 reflect.Value.IsNil 引起的恐慌。 md5:888460104b60f818
func EqualFoldWithoutChars ¶
EqualFoldWithoutChars 检查字符串 `s1` 和 `s2` 是否在大小写不敏感的情况下相等,包括/不包括字符 '-'、'_'、'.' 和 ' '。 md5:e519885b86d35bd5
func FormatCmdKey ¶
FormatCmdKey 使用统一的格式将字符串 `s` 格式化为命令键。 md5:c946276756bc1c34
func FormatEnvKey ¶
FormatEnvKey 使用统一格式对字符串`s`进行格式化,以便作为环境键。 md5:1ded8906c5ce105d
func IsArray ¶
func IsArray(value interface{}) bool
IsArray 检查给定值是否为数组/切片。 注意,它内部使用了反射来实现这个功能。 md5:285200236d9da794
func IsDebugEnabled ¶
func IsDebugEnabled() bool
IsDebugEnabled 检查并返回是否启用了调试模式。 当命令参数 "gf.debug" 或环境变量 "GF_DEBUG" 被设置时,调试模式启用。 md5:df7415f68212ff27
func IsLetterLower ¶
IsLetterLower 检查给定的字节 b 是否为小写。 md5:6f3845d2ae021561
func IsLetterUpper ¶
IsLetterUpper 检查给定字节 b 是否为大写字母。 md5:92d2fefb65d65bd7
func IsNil ¶
func IsNil(value interface{}) bool
IsNil 检查 `value` 是否为 nil,特别是对于 interface{} 类型的值。 md5:7789b39820de4e0c
func IsSlice ¶
func IsSlice(value interface{}) bool
IsSlice 检查 `value` 是否为切片类型。 md5:7ea6cb09ee3f9841
func IsStruct ¶
func IsStruct(value interface{}) bool
IsStruct 检查 `value` 是否为结构体类型。 md5:3be94afb9f9b40ea
func IsUint ¶
func IsUint(value interface{}) bool
IsUint 检查 `value` 是否为 uint 类型。 md5:cc17b6c670e71ccd
func ListToMapByKey ¶
ListToMapByKey 将 `list` 转换为一个键为 `key` 的 map[string]interface{}。注意,项的值可能为切片类型。 md5:6509753e629d5dc6
func MapContainsPossibleKey ¶
MapContainsPossibleKey 检查给定的`key`是否包含在给定的映射`data`中。 它在检查键时忽略大小写和符号。
注意:此函数可能性能较低。 md5:f1b183430304dc85
func MapPossibleItemByKey ¶
func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{})
MapPossibleItemByKey 尝试根据给定键(忽略大小写和符号)找到可能的 key-value 对。
请注意,此函数的性能可能较低。 md5:4dd7c7511eb401cd
func NewReadCloser ¶
func NewReadCloser(content []byte, repeatable bool) io.ReadCloser
NewReadCloser 创建并返回一个 RepeatReadCloser 对象。 md5:5b08470c05886c6e
func RemoveSymbols ¶
RemoveSymbols 从字符串中移除所有符号,只保留数字和字母。 md5:cdaeb32f53496617
func ReplaceByMap ¶
ReplaceByMap 返回一个`origin`的副本, 使用映射无序地替换其中的内容,且区分大小写。 md5:c047c08d8be640ad
func SetDebugEnabled ¶
func SetDebugEnabled(enabled bool)
SetDebugEnabled 启用/禁用内部调试信息。 md5:444b75c65786012e
func SplitAndTrim ¶
SplitAndTrim 通过字符串 `delimiter` 将字符串 `str` 分割成一个数组,然后对数组中的每个元素调用 Trim 函数。它会忽略 Trim 后为空的元素。 md5:20d7e1d120928c19
func StripSlashes ¶
StripSlashes通过AddSlashes方法去引号化一个带引号的字符串。 md5:fdba1646284db234
Types ¶
type ReadCloser ¶
type ReadCloser struct {
// contains filtered or unexported fields
}
ReadCloser 实现了 io.ReadCloser 接口, 该接口用于多次读取请求体内容。
注意,它不能被关闭。 md5:dc906d3f78dd2393
func (*ReadCloser) Close ¶
func (b *ReadCloser) Close() error
Close 实现了 io.ReadCloser 接口。 md5:597e2e893ae16680