Documentation
¶
Index ¶
- Variables
- func AddTime(expr string, v any) time.Time
- func ArrayToBoolMap[T comparable](arr []T) map[T]bool
- func As[T any](v T, err error) T
- func Bool(value any) bool
- func Convert(dst, src any)
- func DescribeDuration(d time.Duration) string
- func Duration(value any) time.Duration
- func FillMap(target any, source any)
- func FillSlice(target any, source any)
- func FixUpperCase(data []byte, excludesKeys []string)
- func Float(value any) float32
- func Float64(value any) float64
- func FormatTime(layout string, v any) string
- func FromJSON[T any](data any) (T, error)
- func GetLowerName(s string) string
- func GetUpperName(s string) string
- func If[T any](condition bool, trueVal, falseVal T) T
- func In[T comparable](arr []T, val T) bool
- func Int(value any) int
- func Int64(value any) int64
- func JoinArgs(arr []string, sep string) string
- func Now() time.Time
- func ParseTime(v any) time.Time
- func PrettyToJSON(value any) string
- func Ptr[T any](v T) *T
- func RealValue(v reflect.Value) reflect.Value
- func SetDefaultTimeZone(loc *time.Location)
- func Split(s, sep string) []string
- func SplitArgs(s string) []string
- func String(value any) string
- func To[T any](v any) T
- func ToFloat64E(v any) (float64, error)
- func ToInt64E(v any) (int64, error)
- func ToJSON(value any) (string, error)
- func ToJSONBytes(value any) ([]byte, error)
- func ToJSONDesensitizeBytes(value any, keys []string) ([]byte, error)
- func ToMap[K comparable, V any](source any) (map[K]V, error)
- func ToSlice[T any](source any) ([]T, error)
- func ToTime(v any, format string) time.Time
- func ToUint64E(v any) (uint64, error)
- func Uint(value any) uint
- func Uint64(value any) uint64
- func UniqueAppend(to []string, from ...any) []string
- func UnmarshalJSON(data any, value any) error
- type TimeZone
- func (tz *TimeZone) AddTime(expr string, v any) time.Time
- func (tz *TimeZone) DescribeDuration(d time.Duration) string
- func (tz *TimeZone) FormatTime(layout string, v any) string
- func (tz *TimeZone) Location() *time.Location
- func (tz *TimeZone) Now() time.Time
- func (tz *TimeZone) ParseTime(v any) time.Time
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTimeZone = NewTimeZone(time.Local)
DefaultTimeZone 全局默认时区,默认为本地时区
Functions ¶
func ArrayToBoolMap ¶ added in v1.0.4
func ArrayToBoolMap[T comparable](arr []T) map[T]bool
func Convert ¶ added in v1.2.3
func Convert(dst, src any)
Convert 深度转换 (支持基础类型、Slice、Map、Struct 及 JSON 自动转换,原地更新)
func DescribeDuration ¶ added in v1.2.5
DescribeDuration 将时长转化为自然语言描述
func FixUpperCase ¶
FixUpperCase (保留以支持历史复杂的 Key 转换需求)
func GetUpperName ¶
func PrettyToJSON ¶ added in v1.0.4
func SetDefaultTimeZone ¶ added in v1.2.3
SetDefaultTimeZone 修改全局默认时区
func ToFloat64E ¶ added in v1.2.0
func ToJSONBytes ¶ added in v1.0.4
func ToJSONDesensitizeBytes ¶ added in v1.1.0
func ToMap ¶ added in v1.1.2
func ToMap[K comparable, V any](source any) (map[K]V, error)
ToMap 泛型构建新 Map
func UniqueAppend ¶ added in v1.0.4
func UnmarshalJSON ¶ added in v1.0.4
Types ¶
type TimeZone ¶ added in v1.2.3
type TimeZone struct {
// contains filtered or unexported fields
}
TimeZone 定义了特定时区上下文下的时间操作
func NewTimeZone ¶ added in v1.2.3
NewTimeZone 创建一个时区上下文
func (*TimeZone) AddTime ¶ added in v1.2.3
AddTime 时间加减 DSL。 格式如: "+1Y-2M+3D", "+1h30m", "-1s"。 单位支持: Y (年), M (月), D (天), h, m, s, ms, us, ns。
func (*TimeZone) DescribeDuration ¶ added in v1.2.5
DescribeDuration 将时长转化为自然语言描述,例如 "1h 1m 1s"
func (*TimeZone) FormatTime ¶ added in v1.2.3
FormatTime 格式化时间。 layout 支持: YYYY-MM-DD HH:mm:ss, YYYY/MM/DD, HH:mm 等直观格式。
Click to show internal directories.
Click to hide internal directories.