Documentation ¶
Overview ¶
包utils提供了一些内部使用的工具函数。
Index ¶
- Variables
- 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 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
- func X是否为Nil(value interface{}) bool
- type ReadCloser
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTrimChars 是默认被 Trim* 函数去除的字符集合。 DefaultTrimChars = string([]byte{ '\t', '\v', '\n', '\r', '\f', ' ', 0x00, 0x85, 0xA0, }) )
Functions ¶
func EqualFoldWithoutChars ¶
EqualFoldWithoutChars 检查字符串 `s1` 和 `s2` 是否不区分大小写相等, 同时在有/无 '-'/'_'/'.'/' ' 这些字符的情况下进行比较。
func IsDebugEnabled ¶
func IsDebugEnabled() bool
IsDebugEnabled 检查并返回是否启用了调试模式。 当命令行参数 "gf.debug" 或环境变量 "GF_DEBUG" 被设置时,调试模式将被启用。
func ListToMapByKey ¶
ListToMapByKey 将 `list` 转换为一个 map[string]interface{},其中键由 `key` 指定。 注意,项的值可能为 slice 类型。
func MapContainsPossibleKey ¶
MapContainsPossibleKey 检查给定的 `key` 是否包含在给定的映射 `data` 中。 它在忽略大小写和符号的情况下检查键值。
注意,此函数可能性能较低。
func MapPossibleItemByKey ¶
func MapPossibleItemByKey(data map[string]interface{}, key string) (foundKey string, foundValue interface{})
MapPossibleItemByKey尝试通过忽略大小写和符号的方式,为给定的键查找可能的键值对。
注意:此函数可能性能较低。
func NewReadCloser ¶
func NewReadCloser(content []byte, repeatable bool) io.ReadCloser
NewReadCloser 创建并返回一个 RepeatReadCloser 对象。
func ReplaceByMap ¶
ReplaceByMap 函数返回 `origin` 的一个副本, 并使用一个无序的映射进行替换,且替换操作区分大小写。
func SplitAndTrim ¶
SplitAndTrim通过字符串`delimiter`将字符串`str`分割成一个数组, 然后对数组中的每个元素调用Trim方法。它会忽略经过Trim处理后为空的元素。
func StripSlashes ¶
StripSlashes 将通过 AddSlashes 方法添加了反斜杠的字符串进行去除引用操作。
Types ¶
type ReadCloser ¶
type ReadCloser struct {
// contains filtered or unexported fields
}
ReadCloser 实现了 io.ReadCloser 接口, 这个接口常用于多次读取请求正文内容。
注意,它不能被关闭。
func (*ReadCloser) Close ¶
func (b *ReadCloser) Close() error
Close 实现了 io.ReadCloser 接口中的 Close 方法。