Documentation ¶
Index ¶
- Constants
- func AddAllowFields(fields ...string)
- func AddAllowSortField(fields ...string)
- func DefFieldFilter(s string) (string, bool)
- func FieldFilter(s string, level FieldFilterLevel, fields ...string) (string, bool)
- func FormUnixToString(t int64, layout string) string
- func GetAgeWithIDCard18(idCard string, refDate time.Time) int
- func GetSexWithIDCard18(idCard string) int
- func IsAdult(idCard string) bool
- func IsAllowFields(field string, allowMap map[string]struct{}) bool
- func IsField(s string) bool
- func Json(data interface{}) string
- func MatchString(s string, exp string) (bool, error)
- func Misty(raw string, b, e int, k string) string
- func MistyDefault(raw string) string
- func MistyMail(raw string) string
- func MistyMobile(raw string) string
- func RandomID() string
- func SetdefaultFieldFilterLevel(level FieldFilterLevel, fields ...string)
- func Sha1ID(data []byte) string
- func Sha1IDSimple(data []byte) string
- func TimeDate(t time.Time) int64
- func TimeFormat(t time.Time) string
- func TimeNumber(t time.Time) int64
- func ToCST(t time.Time) time.Time
- type FieldFilterLevel
Constants ¶
View Source
const ( DefaultTimeFormat = "2006-01-02 15:04:05" NumberTimeFormat = "20060102150405" DateTimeFormat = "20060102" )
View Source
const REGEXP_FIELD = `^[a-zA-Z0-9_]*$` // 定义合法字段名的正则表达式
Variables ¶
This section is empty.
Functions ¶
func AddAllowFields ¶ added in v0.3.30
func AddAllowFields(fields ...string)
AddAllowFields 添加额外允许的字段名到集合中
func AddAllowSortField ¶ added in v0.3.30
func AddAllowSortField(fields ...string)
AddAllowSortField 添加额外允许的排序字段名到集合中(与 AddAllowFields 功能重叠,可能需重构)
func DefFieldFilter ¶ added in v0.3.30
DefFieldFilter 使用默认过滤级别对字段进行过滤
func FieldFilter ¶ added in v0.3.30
func FieldFilter(s string, level FieldFilterLevel, fields ...string) (string, bool)
FieldFilter 根据指定的过滤级别和额外允许的字段对字段进行过滤
func FormUnixToString ¶
layout: 2006-01-02 15:04:05 、 20060102150405 、2006年01月02日 15:04:05
func GetAgeWithIDCard18 ¶
GetAgeWithIDCard18 判断身份证相对于参考时间多少年
func GetSexWithIDCard18 ¶
GetSexWithIDCard18 判断身份证获取性别;-1未知,1性别为男,0则为女
func IsAllowFields ¶ added in v0.3.30
IsAllowFields 检查字段是否在允许的字段集合中
func MatchString ¶ added in v0.3.30
MatchString 使用正则表达式检查字符串是否匹配
func MistyDefault ¶
MistyDefault将给定的字符串进行处理,并返回处理后的字符串。 参数raw为原始字符串。 返回值为处理后的字符串。
func MistyMobile ¶
func SetdefaultFieldFilterLevel ¶ added in v0.3.30
func SetdefaultFieldFilterLevel(level FieldFilterLevel, fields ...string)
SetdefaultFieldFilterLevel 设置默认的字段过滤级别,并添加额外的允许字段
func Sha1IDSimple ¶ added in v0.3.3
Sha1IDSimple 生成一个基于SHA1哈希值的UUID字符串
Types ¶
type FieldFilterLevel ¶ added in v0.3.30
type FieldFilterLevel int32
FieldFilterLevel 定义了字段过滤的级别
const ( FieldFilterLevelDefault FieldFilterLevel = iota // 默认过滤级别 FieldFilterLevelEncode // 编码过滤级别 FieldFilterLevelAssign // 赋值过滤级别 )
FieldFilterLevel 的常量定义
Click to show internal directories.
Click to hide internal directories.