filter

package module
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: BSD-3-Clause Imports: 13 Imported by: 1

README

filter

golang的数据过滤包,由 数据输入、格式化、校验、输出 几个部份组成。

  • 每个步骤都可以自定义错误消息
  • 过滤结果可以自动赋值到变量
  • 支持批量操作,合并错误处理代码
  • 可将过滤规则封装成函数,便于复用

github.com/dxvgef/filter/v2

示例

请参考example_test.go的单元测试代码,如需其它帮助请在Issues里提出。

函数列表

输入
  • FromStr() 输入字符串类型的数据
格式化
  • Trim() 去除前后空格
  • RemoveSpace 去除所有空格
  • ReplaceAll 替换所有
  • ToUpper 字母转为大写
  • ToLower 字母转为小写
  • SnakeCaseToCamelCase 蛇形转驼峰: hello_world => helloWorld
  • SnakeCaseToPascalCase 蛇形转帕斯卡: hello_world => HelloWorld
  • CamelCaseToSnakeCase 驼峰(含帕斯卡)转蛇形 helloWorld/HelloWorld => hello_world
  • HTMLEscape 编码成HTML中显示的字符
  • HTMLUnescape HTMLEscape的解码函数
  • URLPathEscape 编码成能作为URL路径传输的字符
  • URLPathUnescape URLPathEscape的解码函数
  • URLQueryEscape 编码成能作为URL查询参数传输的字符
  • URLQueryUnescape URLQueryEscape的解码函数
  • Base64StdEncode Base64 std 编码
  • Base64StdDecode Base64 std 解码
  • Base64RawStdEncode Base64 raw std 编码
  • Base64RawStdDecode Base64 raw std 解码
  • Base64URLEncode Base64 URL 编码
  • Base64URLDecode Base64 URL 解码
  • Base64RawURLEncode Base64 raw URL 编码
  • Base64RawURLDecode Base64 raw URL 解码
校验
  • Require 参数不能为零值
  • Equal 匹配两个字符串相等
  • MinLength 最小长度
  • MinUTF8Length UTF8编码最小长度
  • MaxLength 最大长度
  • MaxUTF8Length UTF8编码最大长度
  • MinInteger 最小整数值
  • MaxInteger 最大整数值
  • MinFloat 最小浮点值
  • MaxFloat 最大浮点值
  • IsBool 是布尔值
  • IsLower 是小写字母
  • IsUpper 是大写字母
  • IsLetter 是字母
  • IsUnsigned 是无符号数值
  • IsLowerOrNumber 是小写字母或数字
  • IsUpperOrNumber 是大写字母或数字
  • IsLetterOrNumber 是字母或数字
  • IsChinese 是汉字
  • IsMail 是电邮地址
  • IsIP 是IPv4/v6地址
  • IsTCPAddr 是IP:Port格式
  • IsMAC 是MAC地址
  • IsJSON 是有效的JSON格式
  • IsChinaTel 是中国大陆地区固定电话号码
  • IsChinaMobile 是中国大陆地区手机号码
  • IsChinaIDNumber 是中国大陆地区身份证号码
  • IsSQLObject 是SQL对象名(库、表、字段)
  • IsSQLObjects 是SQL对象名集合
  • IsUUID 是UUID格式
  • IsURL 是URL格式
  • HasLetter 必须包含字母
  • HasLower 必须包含小写字母
  • HasUpper 必须包含大写字母
  • HasNumber 必须包含数字
  • HasSymbol 必须包含符号
  • HasPrefix 必须包含指定的前缀字符串
  • HasSuffix 必须包含指定的后缀字符串
  • HasStr 必须包含指定的字符串
  • EnumStr 仅允许[]string中的值
  • EnumInt 仅允许[]int中的值
  • EnumInt32 仅允许[]int32中的值
  • EnumInt64 仅允许[]int64中的值
  • EnumFloat32 仅允许[]float32中的值
  • EnumFloat64 仅允许[]float64中的值
  • EnumStrSlice 将数据转为[]string,并检查其元素是否存在于指定的[]string中
  • EnumIntSlice 将数据转为[]int,并检查其元素是否存在于指定的[]int中
  • DenyStr 阻止[]string中的值
  • DenyInt 阻止[]int中的值
  • DenyInt32 阻止[]int32中的值
  • DenyInt64 阻止[]int64中的值
  • DenyFloat32 阻止[]float32中的值
  • DenyFloat64 阻止[]float64中的值
输出
类型转换
  • String 转为string类型
  • DefaultString 转为string类型,出错则返回默认值
  • SliceString 转为[]string类型
  • DefaultSliceString 转为[]string类型,出错则返回默认值
  • Int 转为int类型
  • DefaultInt 转为int类型,出错则返回默认值
  • SliceInt 转为[]int类型
  • DefaultSliceInt 转为[]int类型,出错则返回默认值
  • Int8 转为int8类型
  • DefaultInt8 转为int8类型,出错则返回默认值
  • SliceInt8 转为[]int8类型
  • DefaultSliceInt8 转为[]int8类型,出错则返回默认值
  • Int16 转为int16类型
  • DefaultInt16 转为int16类型,出错则返回默认值
  • SliceInt16 转为[]int16类型
  • DefaultSliceInt16 转为[]int16类型,出错则返回默认值
  • Int32 转为int32类型
  • DefaultInt32 转为int32类型,出错则返回默认值
  • SliceInt32 转为[]int32类型
  • DefaultSliceInt32 转为[]int32类型,出错则返回默认值
  • Int64 转为int64类型
  • DefaultInt64 转为int64类型,出错则返回默认值
  • SliceInt64 转为[]int64类型
  • DefaultSliceInt64 转为[]int64类型,出错则返回默认值
  • Uint 转为uint类型
  • DefaultUint 转为uint类型,出错则返回默认值
  • SliceUint 转为[]uint类型
  • DefaultSliceUint 转为[]uint类型,出错则返回默认值
  • Uint8 转为uint8类型
  • DefaultUint8 转为uint8类型,出错则返回默认值
  • SliceUint8 转为[]uint8类型
  • DefaultSliceUint8 转为[]uint8类型,出错则返回默认值
  • Uint16 转为uint16类型
  • DefaultUint16 转为uint16类型,出错则返回默认值
  • SliceUint16 转为[]uint16类型
  • DefaultSliceUint16 转为[]uint16类型,出错则返回默认值
  • Uint32 转为uint32类型
  • DefaultUint32 转为uint32类型,出错则返回默认值
  • SliceUint32 转为[]uint32类型
  • DefaultSliceUint32 转为[]uint32类型,出错则返回默认值
  • Uint64 转为uint64类型
  • DefaultUint64 转为uint64类型,出错则返回默认值
  • SliceUint64 转为[]uint64类型
  • DefaultSliceUint64 转为[]uint64类型,出错则返回默认值
  • Float32 转为float32类型
  • DefaultFloat32 转为float32类型,出错则返回默认值
  • SliceFloat32 转为[]float32类型
  • DefaultSliceFloat32 转为[]float32类型,出错则返回默认值
  • Float64 转为float64类型
  • DefaultFloat64 转为float64类型,出错则返回默认值
  • SliceFloat64 转为[]float64类型
  • DefaultSliceFloat64 转为[]float64类型,出错则返回默认值
  • Bool 转为bool类型
  • DefaultBool 转为bool类型,出错则返回默认值
赋值
  • Set 将过滤结果赋值到普通变量
  • SetSlice 将过滤结果赋值到切片变量
结果
  • Error 过滤结果,返回error类型
  • Value 返回当前状态的参数值,主要用于自定义处理函数中获取
  • IsRequire 判断是否执行了Require
自定义处理函数
  • Custom 自定义处理函数,详见CustomFunc类型

Documentation

Index

Constants

View Source
const InvalidErrorText = "invalid data"

InvalidErrorText 无效数据错误提示

Variables

This section is empty.

Functions

func Batch

func Batch(errs ...error) error

Batch 批量处理

Types

type CustomFunc added in v2.4.1

type CustomFunc func(*Str) (string, error)

CustomFunc 自定义处理函数 用*Str.Value()获得当前参数值 用*Str.Error()获得当前错误信息 出参是处理后的参数值和错误信息

type Str

type Str struct {
	// contains filtered or unexported fields
}

Str 输入字符串类型

func FromStr added in v2.4.0

func FromStr(value string, name ...string) *Str

FromStr 输入字符串类型的值

func (*Str) Base64RawStdDecode

func (self *Str) Base64RawStdDecode(customError ...string) *Str

base64 RawStd解码

func (*Str) Base64RawStdEncode

func (self *Str) Base64RawStdEncode() *Str

base64 RawStd编码

func (*Str) Base64RawURLDecode

func (self *Str) Base64RawURLDecode(customError ...string) *Str

base64 RawURL解码

func (*Str) Base64RawURLEncode

func (self *Str) Base64RawURLEncode() *Str

base64 RawURL编码

func (*Str) Base64StdDecode

func (self *Str) Base64StdDecode(customError ...string) *Str

base64 std解码

func (*Str) Base64StdEncode

func (self *Str) Base64StdEncode() *Str

base64 std编码

func (*Str) Base64URLDecode

func (self *Str) Base64URLDecode(customError ...string) *Str

base64 URL解码

func (*Str) Base64URLEncode

func (self *Str) Base64URLEncode() *Str

base64 URL编码

func (*Str) Bool

func (self *Str) Bool() (bool, error)

Bool 转为bool类型

func (*Str) CamelCaseToSnakeCase

func (self *Str) CamelCaseToSnakeCase() *Str

CamelCaseToSnakeCase 驼峰(含帕斯卡)转蛇形 helloWorld/HelloWorld => hello_world

func (*Str) Custom added in v2.4.1

func (self *Str) Custom(f CustomFunc) *Str

Custom 自定义处理方法

func (*Str) DefaultBool

func (self *Str) DefaultBool(def bool) bool

DefaultBool 转为bool类型,如果出错则只返回默认值

func (*Str) DefaultFloat32

func (self *Str) DefaultFloat32(def float32) float32

DefaultFloat32 转为float32类型,如果出错则只返回默认值

func (*Str) DefaultFloat64

func (self *Str) DefaultFloat64(def float64) float64

DefaultFloat64 转为float64类型,如果出错则只返回默认值

func (*Str) DefaultInt

func (self *Str) DefaultInt(def int) int

DefaultInt 转为int类型,如果出错则只返回默认值

func (*Str) DefaultInt16

func (self *Str) DefaultInt16(def int16) int16

DefaultInt16 转为int16类型,如果出错则只返回默认值

func (*Str) DefaultInt32

func (self *Str) DefaultInt32(def int32) int32

DefaultInt32 转为int32类型,如果出错则只返回默认值

func (*Str) DefaultInt64

func (self *Str) DefaultInt64(def int64) int64

DefaultInt64 转为int64类型,如果出错则只返回默认值

func (*Str) DefaultInt8

func (self *Str) DefaultInt8(def int8) int8

DefaultInt8 转为int8类型,如果出错则只返回默认值

func (*Str) DefaultSliceBool

func (self *Str) DefaultSliceBool(sep string, def []bool) []bool

DefaultSliceBool 转为[]bool类型

func (*Str) DefaultSliceFloat32

func (self *Str) DefaultSliceFloat32(sep string, def []float32) []float32

DefaultSliceFloat32 转为[]float32类型

func (*Str) DefaultSliceFloat64

func (self *Str) DefaultSliceFloat64(sep string, def []float64) []float64

DefaultSliceFloat64 转为[]float64类型

func (*Str) DefaultSliceInt

func (self *Str) DefaultSliceInt(sep string, def []int) []int

DefaultSliceInt 转为[]int类型,出错则返回传入的默认值

func (*Str) DefaultSliceInt16

func (self *Str) DefaultSliceInt16(sep string, def []int16) []int16

DefaultSliceInt16 转为[]int16类型

func (*Str) DefaultSliceInt32

func (self *Str) DefaultSliceInt32(sep string, def []int32) []int32

DefaultSliceInt32 转为[]int8类型

func (*Str) DefaultSliceInt64

func (self *Str) DefaultSliceInt64(sep string, def []int64) []int64

DefaultSliceInt64 转为[]int64类型,如果出错则只返回默认值

func (*Str) DefaultSliceInt8

func (self *Str) DefaultSliceInt8(sep string, def []int8) []int8

DefaultSliceInt8 转为[]int8类型,如果出错则只返回默认值

func (*Str) DefaultSliceString

func (self *Str) DefaultSliceString(sep string, def []string) []string

DefaultSliceString 使用SetSeparator()设置的分隔符拆分成[]string类型,如果出错则只返回默认值

func (*Str) DefaultSliceUint

func (self *Str) DefaultSliceUint(sep string, def []uint) []uint

DefaultSliceUint 转为[]int类型,出错则返回传入的默认值

func (*Str) DefaultSliceUint16

func (self *Str) DefaultSliceUint16(sep string, def []uint16) []uint16

DefaultSliceUint16 转为[]uint16类型

func (*Str) DefaultSliceUint32

func (self *Str) DefaultSliceUint32(sep string, def []uint32) []uint32

DefaultSliceUint32 转为[]uint8类型

func (*Str) DefaultSliceUint64

func (self *Str) DefaultSliceUint64(sep string, def []uint64) []uint64

DefaultSliceUint64 转为[]uint64类型,如果出错则只返回默认值

func (*Str) DefaultSliceUint8

func (self *Str) DefaultSliceUint8(sep string, def []uint8) []uint8

DefaultSliceUint8 转为[]uint8类型,如果出错则只返回默认值

func (*Str) DefaultString

func (self *Str) DefaultString(def string) string

DefaultString 转为string类型,如果出错则只返回默认值

func (*Str) DefaultUint

func (self *Str) DefaultUint(def uint) uint

DefaultUint 转为uint类型,如果出错则只返回默认值

func (*Str) DefaultUint16

func (self *Str) DefaultUint16(def uint16) uint16

DefaultUint16 转为uint16类型,如果出错则只返回默认值

func (*Str) DefaultUint32

func (self *Str) DefaultUint32(def uint32) uint32

DefaultUint32 转为uint32类型,如果出错则只返回默认值

func (*Str) DefaultUint64

func (self *Str) DefaultUint64(def uint64) uint64

DefaultUint64 转为uint64类型,如果出错则只返回默认值

func (*Str) DefaultUint8

func (self *Str) DefaultUint8(def uint8) uint8

DefaultUint8 转为uint8类型,如果出错则只返回默认值

func (*Str) DenyFloat32

func (self *Str) DenyFloat32(f []float32, customError ...string) *Str

DenyFloat32 阻止[]float32中的值

func (*Str) DenyFloat64

func (self *Str) DenyFloat64(f []float64, customError ...string) *Str

DenyFloats64 阻止[]float64中的值

func (*Str) DenyInt

func (self *Str) DenyInt(i []int, customError ...string) *Str

DenyInt 阻止[]int中的值

func (*Str) DenyInt16

func (self *Str) DenyInt16(i []int16, customError ...string) *Str

DenyInt16 阻止[]int16中的值

func (*Str) DenyInt32

func (self *Str) DenyInt32(i []int32, customError ...string) *Str

DenyInt32 阻止[]int32中的值

func (*Str) DenyInt64

func (self *Str) DenyInt64(i []int64, customError ...string) *Str

DenyInt64 阻止[]int64中的值

func (*Str) DenyInt8

func (self *Str) DenyInt8(i []int8, customError ...string) *Str

DenyInt8 阻止[]int8中的值

func (*Str) DenyStr added in v2.4.0

func (self *Str) DenyStr(slice []string, customError ...string) *Str

DenyStr 阻止[]string中的值

func (*Str) EnumFloat32

func (self *Str) EnumFloat32(f []float32, customError ...string) *Str

EnumFloat32 仅允许[]float32中的值

func (*Str) EnumFloat64

func (self *Str) EnumFloat64(f []float64, customError ...string) *Str

EnumFloat64 仅允许[]float64中的值

func (*Str) EnumInt

func (self *Str) EnumInt(i []int, customError ...string) *Str

EnumInt 仅允许[]int中的值

func (*Str) EnumInt16

func (self *Str) EnumInt16(i []int16, customError ...string) *Str

EnumInt16 仅允许[]int16中的值

func (*Str) EnumInt32

func (self *Str) EnumInt32(i []int32, customError ...string) *Str

EnumInt32 仅允许[]int32中的值

func (*Str) EnumInt64

func (self *Str) EnumInt64(i []int64, customError ...string) *Str

EnumInt64 仅允许[]int64中的值

func (*Str) EnumInt8

func (self *Str) EnumInt8(i []int8, customError ...string) *Str

EnumInt8 仅允许[]int8中的值

func (*Str) EnumIntSlice added in v2.4.0

func (self *Str) EnumIntSlice(sep string, slice []int, customError ...string) *Str

EnumIntSlice 检查[]string中的元素,仅允许指潘秉衡[]int中的值

func (*Str) EnumStr added in v2.4.0

func (self *Str) EnumStr(slice []string, customError ...string) *Str

EnumStr 仅允许[]string中的值

func (*Str) EnumStrSlice added in v2.4.0

func (self *Str) EnumStrSlice(sep string, slice []string, customError ...string) *Str

EnumStrSlice 检查[]string中的元素,仅允许指定[]string中的值

func (*Str) Equal

func (self *Str) Equal(str string, customError ...string) *Str

Equal 与指定的字符串相等

func (*Str) Error

func (self *Str) Error() error

Error 获得错误信息

func (*Str) Float32

func (self *Str) Float32() (float32, error)

Float32 转为float32类型

func (*Str) Float64

func (self *Str) Float64() (float64, error)

Float64 转为float64类型

func (*Str) HTMLEscape

func (self *Str) HTMLEscape() *Str

html.EscapeString

func (*Str) HTMLUnescape

func (self *Str) HTMLUnescape() *Str

html.UnescapeString

func (*Str) HasLetter

func (self *Str) HasLetter(customError ...string) *Str

必须包含字母(不区分大小写)

func (*Str) HasLower

func (self *Str) HasLower(customError ...string) *Str

HasLower 必须包含小写字母

func (*Str) HasNumber added in v2.4.0

func (self *Str) HasNumber(customError ...string) *Str

HasNumber 必须包含数字

func (*Str) HasPrefix

func (self *Str) HasPrefix(sub string, customError ...string) *Str

HasPrefix 必须包含指定的前缀字符串

func (*Str) HasStr added in v2.4.0

func (self *Str) HasStr(sub string, customError ...string) *Str

HasStr 必须包含指定的字符串

func (*Str) HasSuffix

func (self *Str) HasSuffix(sub string, customError ...string) *Str

HasSuffix 必须包含指定的后缀字符串

func (*Str) HasSymbol

func (self *Str) HasSymbol(customError ...string) *Str

HasSymbol 必须包含符号

func (*Str) HasUpper

func (self *Str) HasUpper(customError ...string) *Str

HasUpper 必须包含大写字母

func (*Str) Int

func (self *Str) Int() (int, error)

Int 转为int类型

func (*Str) Int16

func (self *Str) Int16() (int16, error)

Int16 转为int16类型

func (*Str) Int32

func (self *Str) Int32() (int32, error)

Int32 转为int32类型

func (*Str) Int64

func (self *Str) Int64() (int64, error)

Int64 转为int64类型

func (*Str) Int8

func (self *Str) Int8() (int8, error)

Int8 转为int8类型

func (*Str) IsBool

func (self *Str) IsBool(customError ...string) *Str

IsBool 布尔值

func (*Str) IsChinaIDNumber

func (self *Str) IsChinaIDNumber(customError ...string) *Str

IsChinaIDNumber 中国身份证号码

func (*Str) IsChinaMobile

func (self *Str) IsChinaMobile(customError ...string) *Str

IsChinaMobile 中国手机号码

func (*Str) IsChinaTel

func (self *Str) IsChinaTel(customError ...string) *Str

IsChinaTel 中国固定电话号码

func (*Str) IsChinese

func (self *Str) IsChinese(customError ...string) *Str

IsChinese 汉字

func (*Str) IsIP

func (self *Str) IsIP(customError ...string) *Str

IsIP IPv4/v6地址

func (*Str) IsJSON

func (self *Str) IsJSON(customError ...string) *Str

IsJSON JSON格式

func (*Str) IsLetter

func (self *Str) IsLetter(customError ...string) *Str

IsLetter 大小写字母

func (*Str) IsLetterOrNumber added in v2.4.0

func (self *Str) IsLetterOrNumber(customError ...string) *Str

IsLetterOrNumber 字母或数字

func (*Str) IsLower

func (self *Str) IsLower(customError ...string) *Str

IsLower 小写字母

func (*Str) IsLowerOrNumber added in v2.4.0

func (self *Str) IsLowerOrNumber(customError ...string) *Str

IsLowerOrNumber 小写字母或数字

func (*Str) IsMAC

func (self *Str) IsMAC(customError ...string) *Str

IsMAC MAC地址

func (*Str) IsMail

func (self *Str) IsMail(customError ...string) *Str

IsMail 电邮地址

func (*Str) IsRequire added in v2.4.1

func (self *Str) IsRequire() bool

IsRequire 判断是否必须

func (*Str) IsSQLObject

func (self *Str) IsSQLObject(customError ...string) *Str

IsSQLObject SQL对象(库名、表名、字段名)

func (*Str) IsSQLObjects

func (self *Str) IsSQLObjects(sep string, customError ...string) *Str

IsSQLObjects SQL对象集合(库名、表名、字段名)

func (*Str) IsTCPAddr

func (self *Str) IsTCPAddr(customError ...string) *Str

IsTCPAddr IP:Port

func (*Str) IsURL

func (self *Str) IsURL(customError ...string) *Str

IsURL 是有效的URL

func (*Str) IsUUID

func (self *Str) IsUUID(customError ...string) *Str

IsUUID UUID格式

func (*Str) IsUnsigned added in v2.4.0

func (self *Str) IsUnsigned(customError ...string) *Str

IsUnsigned 无符号数值

func (*Str) IsUpper

func (self *Str) IsUpper(customError ...string) *Str

IsUpper 大写字母

func (*Str) IsUpperOrNumber added in v2.4.0

func (self *Str) IsUpperOrNumber(customError ...string) *Str

IsUpperOrNumber 大写字母或数字

func (*Str) JoinByte

func (self *Str) JoinByte(values ...byte) *Str

JoinByte 拼接byte

func (*Str) JoinBytes

func (self *Str) JoinBytes(values ...[]byte) *Str

JoinBytes 拼接bytes

func (*Str) JoinRune

func (self *Str) JoinRune(values ...rune) *Str

JoinRune 拼接rune

func (*Str) JoinStr

func (self *Str) JoinStr(values ...string) *Str

拼接string

func (*Str) MaxFloat

func (self *Str) MaxFloat(max float64, customError ...string) *Str

MaxFloat 最大浮点值

func (*Str) MaxInteger

func (self *Str) MaxInteger(max int64, customError ...string) *Str

MaxInteger 最大整数值

func (*Str) MaxLength

func (self *Str) MaxLength(max int, customError ...string) *Str

MaxLength 最大长度

func (*Str) MaxUTF8Length

func (self *Str) MaxUTF8Length(max int, customError ...string) *Str

MaxUTF8Length UTF8编码最大长度

func (*Str) MinFloat

func (self *Str) MinFloat(min float64, customError ...string) *Str

MinFloat 最小浮点值

func (*Str) MinInteger

func (self *Str) MinInteger(min int64, customError ...string) *Str

MinInteger 最小整数值

func (*Str) MinLength

func (self *Str) MinLength(min int, customError ...string) *Str

MinLength 最小长度

func (*Str) MinUTF8Length

func (self *Str) MinUTF8Length(min int, customError ...string) *Str

MinUTF8Length UTF8编码最小长度

func (*Str) RemoveSpace

func (self *Str) RemoveSpace() *Str

RemoveSpace 删除所有空格

func (*Str) Require

func (self *Str) Require(customError ...string) *Str

Require 必须有值(不能为零值)

func (*Str) Set

func (self *Str) Set(target interface{}, customError ...string) error

赋值到普通对象

func (*Str) SetSlice

func (self *Str) SetSlice(target interface{}, sep string, customError ...string) error

func (*Str) SliceBool

func (self *Str) SliceBool(sep string) (result []bool, err error)

SliceBool 转为[]bool类型

func (*Str) SliceFloat32

func (self *Str) SliceFloat32(sep string) (result []float32, err error)

SliceFloat32 转为[]float32类型

func (*Str) SliceFloat64

func (self *Str) SliceFloat64(sep string) (result []float64, err error)

SliceFloat64 转为[]float64类型

func (*Str) SliceInt

func (self *Str) SliceInt(sep string) (result []int, err error)

SliceInt 转为[]int类型

func (*Str) SliceInt16

func (self *Str) SliceInt16(sep string) (result []int16, err error)

SliceInt16 转为[]int16类型

func (*Str) SliceInt32

func (self *Str) SliceInt32(sep string) (result []int32, err error)

SliceInt32 转为[]int32类型

func (*Str) SliceInt64

func (self *Str) SliceInt64(sep string) (result []int64, err error)

SliceInt64 转为[]int64类型

func (*Str) SliceInt8

func (self *Str) SliceInt8(sep string) (result []int8, err error)

SliceInt8 转为[]int8类型

func (*Str) SliceString

func (self *Str) SliceString(sep string) ([]string, error)

SliceString 使用SetSeparator()设置的分隔符拆分成[]string类型

func (*Str) SliceUint

func (self *Str) SliceUint(sep string) (result []uint, err error)

SliceUint 转为[]int类型

func (*Str) SliceUint16

func (self *Str) SliceUint16(sep string) (result []uint16, err error)

SliceUint16 转为[]uint16类型

func (*Str) SliceUint32

func (self *Str) SliceUint32(sep string) (result []uint32, err error)

SliceUint32 转为[]uint32类型

func (*Str) SliceUint64

func (self *Str) SliceUint64(sep string) (result []uint64, err error)

SliceUint64 转为[]uint64类型

func (*Str) SliceUint8

func (self *Str) SliceUint8(sep string) (result []uint8, err error)

SliceUint8 转为[]int8类型

func (*Str) SnakeCaseToCamelCase

func (self *Str) SnakeCaseToCamelCase() *Str

SnakeCaseToCamelCase 蛇形转驼峰: hello_world => helloWorld

func (*Str) SnakeCaseToPascalCase

func (self *Str) SnakeCaseToPascalCase() *Str

SnakeCaseToPascalCase 蛇形转帕斯卡: hello_world => HelloWorld

func (*Str) String

func (self *Str) String() (string, error)

FromStr 转为string类型

func (*Str) ToLower

func (self *Str) ToLower() *Str

字母转为小写

func (*Str) ToUpper

func (self *Str) ToUpper() *Str

字母转为大写

func (*Str) Trim

func (self *Str) Trim(sub string) *Str

Trim 删除左右的指定字符串

func (*Str) TrimLeft

func (self *Str) TrimLeft(sub string) *Str

TrimLeft 删除左边的指定字符串

func (*Str) TrimPrefix

func (self *Str) TrimPrefix(sub string) *Str

TrimPrefix 删除指定的前缀字符串

func (*Str) TrimRight

func (self *Str) TrimRight(sub string) *Str

TrimRight 删除右边的指定字符串

func (*Str) TrimSpace

func (self *Str) TrimSpace() *Str

TrimSpace 删除左右的空格

func (*Str) TrimSuffix

func (self *Str) TrimSuffix(sub string) *Str

TrimSuffix 删除指定的后缀字符串

func (*Str) URLPathEscape

func (self *Str) URLPathEscape() *Str

与url.PathEscape相同

func (*Str) URLPathUnescape

func (self *Str) URLPathUnescape(customError ...string) *Str

url.PathUnescape

func (*Str) URLQueryEscape

func (self *Str) URLQueryEscape() *Str

URLQueryEscape 与url.QueryEscape相同

func (*Str) URLQueryUnescape

func (self *Str) URLQueryUnescape(customError ...string) *Str

与url.QueryUnescape相同

func (*Str) Uint

func (self *Str) Uint() (uint, error)

Uint 转为uint类型

func (*Str) Uint16

func (self *Str) Uint16() (uint16, error)

Uint16 转为uint16类型

func (*Str) Uint32

func (self *Str) Uint32() (uint32, error)

Uint32 转为uint32类型

func (*Str) Uint64

func (self *Str) Uint64() (uint64, error)

Uint64 转为uint64类型

func (*Str) Uint8

func (self *Str) Uint8() (uint8, error)

Uint8 转为uint8类型

func (*Str) Value added in v2.4.1

func (self *Str) Value() string

Value 获得当前参数值

Jump to

Keyboard shortcuts

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