Documentation
¶
Index ¶
- Constants
- func DecryptString(ciphertext string, key []byte) (string, error)
- func EncryptString(text string, key []byte) (string, error)
- func FormatDate(t time.Time) string
- func FormatTime(t time.Time) string
- func FormatTimeWithMilli(t time.Time) string
- func FormatTimeWithZone(t time.Time) string
- func GenerateToken(length int) (string, error)
- func GetEndOfDay(t time.Time) time.Time
- func GetEndOfMonth(t time.Time) time.Time
- func GetEndOfWeek(t time.Time) time.Time
- func GetStartOfDay(t time.Time) time.Time
- func GetStartOfMonth(t time.Time) time.Time
- func GetStartOfWeek(t time.Time) time.Time
- func HashPassword(password string) (string, error)
- func IsThisMonth(t time.Time) bool
- func IsThisWeek(t time.Time) bool
- func IsToday(t time.Time) bool
- func MakeAllFieldsRequired(schema *openapi3.Schema)
- func ParseDate(s string) (time.Time, error)
- func ParseTime(s string) (time.Time, error)
- func ParseTimeWithMilli(s string) (time.Time, error)
- func ParseTimeWithZone(s string) (time.Time, error)
- func Ternary[T any](condition bool, trueValue, falseValue T) T
- func VerifyPassword(hashedPassword, password string) bool
- type ParserState
- type PathMatcherCallback
- type PathPattern
- type SimplePathMatcher
- type StreamingJsonParser
Constants ¶
const ( // TimeFormat 标准时间格式 TimeFormat = "2006-01-02 15:04:05" // DateFormat 标准日期格式 DateFormat = "2006-01-02" // TimeFormatWithZone 带时区的时间格式 TimeFormatWithZone = "2006-01-02 15:04:05 -0700" // TimeFormatWithMilli 带毫秒的时间格式 TimeFormatWithMilli = "2006-01-02 15:04:05.000" )
Variables ¶
This section is empty.
Functions ¶
func DecryptString ¶
DecryptString 解密字符串
func EncryptString ¶
EncryptString 加密字符串
func FormatTimeWithMilli ¶
FormatTimeWithMilli 格式化时间为带毫秒的字符串
func FormatTimeWithZone ¶
FormatTimeWithZone 格式化时间为带时区的字符串
func HashPassword ¶
HashPassword 使用 bcrypt 对密码进行哈希
func MakeAllFieldsRequired ¶
递归设置所有嵌套Schema的additionalProperties为false并使所有字段required
func ParseTimeWithMilli ¶
ParseTimeWithMilli 解析带毫秒的时间字符串
func ParseTimeWithZone ¶
ParseTimeWithZone 解析带时区的时间字符串
func Ternary ¶
Ternary 三元表达式工具函数 condition: 条件表达式 trueValue: 条件为真时的返回值 falseValue: 条件为假时的返回值 返回: 根据条件返回对应的值
func VerifyPassword ¶
VerifyPassword 验证密码是否匹配
Types ¶
type ParserState ¶
type ParserState int
ParserState JSON 解析器的状态类型
const ( VALUE ParserState = iota KEY_OR_END KEY COLON COMMA VALUE_OR_END NUMBER TRUE1 TRUE2 TRUE3 FALSE1 FALSE2 FALSE3 FALSE4 NULL1 NULL2 NULL3 )
type PathMatcherCallback ¶
type PathMatcherCallback func(value interface{}, path []interface{})
PathMatcherCallback 路径匹配器的回调函数类型
type PathPattern ¶
type PathPattern struct {
Tokens []interface{} // 解析后的标记数组
Original string // 原始模式字符串
Callback PathMatcherCallback
}
PathPattern 路径匹配模式类型
type SimplePathMatcher ¶
type SimplePathMatcher struct {
// contains filtered or unexported fields
}
SimplePathMatcher 简化版 JSON 路径匹配系统
func NewSimplePathMatcher ¶
func NewSimplePathMatcher() *SimplePathMatcher
NewSimplePathMatcher 创建新的路径匹配器
func (*SimplePathMatcher) CheckPatterns ¶
func (m *SimplePathMatcher) CheckPatterns(path []interface{}, value interface{})
CheckPatterns 检查当前路径是否匹配任何注册的模式
func (*SimplePathMatcher) On ¶
func (m *SimplePathMatcher) On(pattern string, callback PathMatcherCallback) *SimplePathMatcher
On 注册一个路径模式和对应的回调函数
type StreamingJsonParser ¶
type StreamingJsonParser struct {
// contains filtered or unexported fields
}
StreamingJsonParser 真实的流式 JSON 解析器
func NewStreamingJsonParser ¶
func NewStreamingJsonParser(matcher *SimplePathMatcher, realtime bool, incremental bool) *StreamingJsonParser
NewStreamingJsonParser 创建新的流式JSON解析器 realtime: 控制是否实时返回解析结果 incremental: 控制是返回增量内容(true)还是累积内容(false)
func (*StreamingJsonParser) GetResult ¶
func (p *StreamingJsonParser) GetResult() interface{}
GetResult 获取解析结果
func (*StreamingJsonParser) Write ¶
func (p *StreamingJsonParser) Write(chunk string) error
Write 逐字符处理输入流