Documentation
¶
Index ¶
- Constants
- func Any2String(v any) string
- func ArgsRange(args Args, handle func(k string, v Value))
- func Bool2String(b bool) string
- func Date2String(t time.Time) string
- func Float642String(f float64) string
- func Int2String(i int) string
- func Int642String(i int64) string
- func PrintTree[T any](tree []*TreeNode[T], indent string)
- func String2Bool(s string) bool
- func String2Date(s string) time.Time
- func String2Float64(s string) float64
- func String2Int(s string) int
- func String2Int64(s string) int64
- func String2Time(s string) time.Time
- func Time2String(t time.Time) string
- type Args
- type Bool
- func (x *Bool) Bool(def ...bool) bool
- func (x *Bool) Cover(v any)
- func (x *Bool) Float64(def ...float64) float64
- func (x *Bool) Int(def ...int) int
- func (x *Bool) Int64(def ...int64) int64
- func (x *Bool) MarshalJSON() ([]byte, error)
- func (x *Bool) String(def ...string) string
- func (x *Bool) UnmarshalJSON(bytes []byte) error
- func (x *Bool) Valid() bool
- func (x *Bool) Value(def ...bool) bool
- type Collect
- type CollectAny
- type CollectString
- type CollectValue
- type Date
- type Enum
- func (e *Enum[K, V]) Add(k K, v V) *Enum[K, V]
- func (e *Enum[K, V]) Clear()
- func (e *Enum[K, V]) Find(k K) (V, bool)
- func (e *Enum[K, V]) Get(k K) V
- func (e *Enum[K, V]) Keys() []K
- func (e *Enum[K, V]) Len() int
- func (e *Enum[K, V]) Put(k K, v V)
- func (e *Enum[K, V]) Range(handle func(k K, v V) bool)
- func (e *Enum[K, V]) RangeWithIndex(handle func(i int, k K, v V) bool)
- func (e *Enum[K, V]) Remove(k K)
- func (e *Enum[K, V]) Values() []V
- type Float64
- func (x *Float64) Bool(def ...bool) bool
- func (x *Float64) Cover(v any)
- func (x *Float64) Float64(def ...float64) float64
- func (x *Float64) Int(def ...int) int
- func (x *Float64) Int64(def ...int64) int64
- func (x *Float64) MarshalJSON() ([]byte, error)
- func (x *Float64) String(def ...string) string
- func (x *Float64) UnmarshalJSON(bytes []byte) error
- func (x *Float64) Valid() bool
- func (x *Float64) Value(def ...float64) float64
- type Int
- func (x *Int) Bool(def ...bool) bool
- func (x *Int) Cover(v any)
- func (x *Int) Float64(def ...float64) float64
- func (x *Int) Int(def ...int) int
- func (x *Int) Int64(def ...int64) int64
- func (x *Int) MarshalJSON() ([]byte, error)
- func (x *Int) String(def ...string) string
- func (x *Int) UnmarshalJSON(bytes []byte) error
- func (x *Int) Valid() bool
- func (x *Int) Value(def ...int) int
- type Int64
- func (x *Int64) Bool(def ...bool) bool
- func (x *Int64) Cover(v any)
- func (x *Int64) Float64(def ...float64) float64
- func (x *Int64) Int(def ...int) int
- func (x *Int64) Int64(def ...int64) int64
- func (x *Int64) MarshalJSON() ([]byte, error)
- func (x *Int64) String(def ...string) string
- func (x *Int64) UnmarshalJSON(bytes []byte) error
- func (x *Int64) Valid() bool
- func (x *Int64) Value(def ...int64) int64
- type JSON
- type Link
- type Set
- type String
- func (x *String) Bool(def ...bool) bool
- func (x *String) Cover(v any)
- func (x *String) Float64(def ...float64) float64
- func (x *String) Int(def ...int) int
- func (x *String) Int64(def ...int64) int64
- func (x *String) MarshalJSON() ([]byte, error)
- func (x *String) String(def ...string) string
- func (x *String) UnmarshalJSON(bytes []byte) error
- func (x *String) Valid() bool
- func (x *String) Value(def ...string) string
- type Time
- func (x *Time) Bool(def ...bool) bool
- func (x *Time) Cover(v any)
- func (x *Time) Float64(def ...float64) float64
- func (x *Time) Int(def ...int) int
- func (x *Time) Int64(def ...int64) int64
- func (x *Time) MarshalJSON() ([]byte, error)
- func (x *Time) String(def ...string) string
- func (x *Time) UnmarshalJSON(bytes []byte) error
- func (x *Time) Valid() bool
- func (x *Time) Value(def ...time.Time) time.Time
- type TreeNode
- type Value
- type Zero
- func (z *Zero) Bool(...bool) bool
- func (z *Zero) Cover(_ any)
- func (z *Zero) Float64(...float64) float64
- func (z *Zero) Int(...int) int
- func (z *Zero) Int64(...int64) int64
- func (z *Zero) MarshalJSON() ([]byte, error)
- func (z *Zero) String(...string) string
- func (z *Zero) UnmarshalJSON(_ []byte) error
- func (z *Zero) Valid() bool
Constants ¶
View Source
const ( TimeLayout = "2006-01-02 15:04:05" DateLayout = "2006-01-02" )
Variables ¶
This section is empty.
Functions ¶
func Date2String ¶ added in v1.25.6
func Float642String ¶ added in v1.25.6
Float642String 将浮点数值格式化为字符串
func String2Float64 ¶ added in v1.25.6
String2Float64 将字符串解析为浮点数值
Types ¶
type Args ¶ added in v1.25.5
Args 参数收集器,隐式实现了 CollectValue 可被json序列化,但是不可被json反序列化,
func (Args) UnmarshalJSON ¶ added in v1.25.5
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool 布尔值
func (*Bool) MarshalJSON ¶
func (*Bool) UnmarshalJSON ¶
type Collect ¶ added in v1.25.5
type Collect[K comparable, V any] interface { Put(k K, v V) // 放入值 Get(k K) V // 获取值 }
type CollectAny ¶ added in v1.25.5
type CollectString ¶ added in v1.25.5
type CollectValue ¶ added in v1.25.5
type Enum ¶
type Enum[K comparable, V any] struct { // contains filtered or unexported fields }
Enum 枚举类,实现了Collect[K, V]接口
func NewStringEnum ¶
NewStringEnum key为string类型,value为任意类型
func (*Enum[K, V]) RangeWithIndex ¶ added in v1.25.2
RangeWithIndex 遍历枚举值,包含下标
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 浮点数值
func (*Float64) MarshalJSON ¶
func (*Float64) UnmarshalJSON ¶
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int 整数值
func (*Int) MarshalJSON ¶
func (*Int) UnmarshalJSON ¶
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 整数值
func (*Int64) MarshalJSON ¶
func (*Int64) UnmarshalJSON ¶
type Link ¶ added in v1.25.3
type Link[T any] struct { // contains filtered or unexported fields }
type Set ¶ added in v1.26.4
type Set[T comparable] struct { // contains filtered or unexported fields }
Set 泛型集合,并发安全
type String ¶
type String struct {
// contains filtered or unexported fields
}
String 字符串值
func (*String) MarshalJSON ¶
func (*String) UnmarshalJSON ¶
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
func (*Time) MarshalJSON ¶
func (*Time) UnmarshalJSON ¶
type TreeNode ¶
type TreeNode[T any] struct { Id string `json:"id"` Pid string `json:"pid"` Depth int `json:"depth"` Data T `json:"data"` Children []*TreeNode[T] `json:"children"` }
TreeNode 树形节点
func Convert2Tree ¶
Convert2Tree 平铺数组转为树形结构
type Value ¶
type Value interface {
Valid() bool // 是否有效
Cover(v any) // 覆盖值
String(def ...string) string // 转为字符串,若无效则返回默认值
Int(def ...int) int // 转为整数,若无效则返回默认值
Int64(def ...int64) int64 // 转为整数,若无效则返回默认值
Float64(def ...float64) float64 // 转为浮点数,若无效则返回默认值
Bool(def ...bool) bool // 转为布尔值,若无效则返回默认值
}
Value 任意值
type Zero ¶
type Zero struct{}
Zero 零值
func (*Zero) MarshalJSON ¶ added in v1.25.5
func (*Zero) UnmarshalJSON ¶ added in v1.25.5
Click to show internal directories.
Click to hide internal directories.