utils

package
v0.0.0-...-fcd50c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

包utils提供了一些内部使用的工具函数。 md5:7bf96340b2779144

Index

Constants

This section is empty.

Variables

View Source
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

func EqualFoldWithoutChars(s1, s2 string) bool

EqualFoldWithoutChars 检查字符串 `s1` 和 `s2` 是否在大小写不敏感的情况下相等,包括/不包括字符 '-'、'_'、'.' 和 ' '。 md5:e519885b86d35bd5

func FormatCmdKey

func FormatCmdKey(s string) string

FormatCmdKey 使用统一的格式将字符串 `s` 格式化为命令键。 md5:c946276756bc1c34

func FormatEnvKey

func FormatEnvKey(s string) string

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 IsEmpty

func IsEmpty(value interface{}) bool

IsEmpty 检查 `value` 是否为空。 md5:b2015a35f4930a22

func IsFloat

func IsFloat(value interface{}) bool

IsFloat检查`value`是否为浮点类型。 md5:11f3d9e95720de15

func IsInt

func IsInt(value interface{}) bool

IsInt 检查 `value` 是否为 int 类型。 md5:f996dc2da0e38f8d

func IsLetter

func IsLetter(b byte) bool

IsLetter 检查给定的字节b是否为字母。 md5:f483df3b4a456648

func IsLetterLower

func IsLetterLower(b byte) bool

IsLetterLower 检查给定的字节 b 是否为小写。 md5:6f3845d2ae021561

func IsLetterUpper

func IsLetterUpper(b byte) bool

IsLetterUpper 检查给定字节 b 是否为大写字母。 md5:92d2fefb65d65bd7

func IsMap

func IsMap(value interface{}) bool

IsMap 检查 `value` 是否为映射类型。 md5:a3bcf5df99373e2a

func IsNil

func IsNil(value interface{}) bool

IsNil 检查 `value` 是否为 nil,特别是对于 interface{} 类型的值。 md5:7789b39820de4e0c

func IsNumeric

func IsNumeric(s string) bool

IsNumeric 检查给定的字符串 s 是否为数字。 注意,像 "123.456" 这样的浮点数字符串也被视为数字。 md5:630bec1763c4d982

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

func ListToMapByKey(list []map[string]interface{}, key string) map[string]interface{}

ListToMapByKey 将 `list` 转换为一个键为 `key` 的 map[string]interface{}。注意,项的值可能为切片类型。 md5:6509753e629d5dc6

func MapContainsPossibleKey

func MapContainsPossibleKey(data map[string]interface{}, key string) bool

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

func RemoveSymbols(s string) string

RemoveSymbols 从字符串中移除所有符号,只保留数字和字母。 md5:cdaeb32f53496617

func ReplaceByMap

func ReplaceByMap(origin string, replaces map[string]string) string

ReplaceByMap 返回一个`origin`的副本, 使用映射无序地替换其中的内容,且区分大小写。 md5:c047c08d8be640ad

func SetDebugEnabled

func SetDebugEnabled(enabled bool)

SetDebugEnabled 启用/禁用内部调试信息。 md5:444b75c65786012e

func SplitAndTrim

func SplitAndTrim(str, delimiter string, characterMask ...string) []string

SplitAndTrim 通过字符串 `delimiter` 将字符串 `str` 分割成一个数组,然后对数组中的每个元素调用 Trim 函数。它会忽略 Trim 后为空的元素。 md5:20d7e1d120928c19

func StripSlashes

func StripSlashes(str string) string

StripSlashes通过AddSlashes方法去引号化一个带引号的字符串。 md5:fdba1646284db234

func Trim

func Trim(str string, characterMask ...string) string

Trim 函数从字符串的开头和结尾删除空白符(或其他字符)。 可选参数 `characterMask` 指定了额外需要删除的字符。 md5:a1d794d7a10c9c7a

func UcFirst

func UcFirst(s string) string

UcFirst 返回一个字符串s的副本,其中第一个字母映射为其大写形式。 md5:bc090531eef4b3e6

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

func (*ReadCloser) Read

func (b *ReadCloser) Read(p []byte) (n int, err error)

Read implements the io.ReadCloser接口。 md5:a139bded6161151f

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL