Documentation
¶
Index ¶
- Constants
- func DeJSONalizeStr(s string, v any) error
- func DelayDo(d time.Duration, fn func())
- func GetNextColor() color
- func Hold()
- func IsDev() bool
- func IsDigits(s string) bool
- func IsNil[T any](v T) bool
- func JSONalizeStr(v any) string
- func LogMessage(message string)
- func PPrettyPrint(v any)
- func PPrint(obj interface{})
- func PrettyObjStr(v any) string
- func PrintlnColor(c color, text string)
- func RetryWork(work func() (any, error), retryTimes int) (any, error)
- func TimeoutWork(work func() (any, error), timeout time.Duration) (any, error)
- type Number
Constants ¶
View Source
const ( Red color = iota Green BrightBlue Magenta // 紫色 Cyan // 青色 )
Variables ¶
This section is empty.
Functions ¶
func DeJSONalizeStr ¶ added in v0.31.0
DeJSONalizeStr 将 JSON 字符串解码到 v 指向的值中。 v 必须是非 nil 的指针,否则返回 error。
func GetNextColor ¶ added in v0.18.0
func GetNextColor() color
func IsNil ¶ added in v0.19.0
IsNil returns true if v is a nil value for nilable kinds or an untyped nil interface.
func JSONalizeStr ¶ added in v0.31.0
JSONalizeStr 尝试将任意对象编码为漂亮的 JSON 字符串;若 JSON 编码失败,则回退到 PrettyObjStr。
func LogMessage ¶
func LogMessage(message string)
func PPrettyPrint ¶ added in v0.31.0
func PPrettyPrint(v any)
PPrettyPrint 使用 spew 打印任意对象(更接近 Python pprint)
func PrettyObjStr ¶ added in v0.31.0
PrettyObjStr 返回对象的漂亮字符串表示(不打印,供日志/前端返回)
Types ¶
type Number ¶ added in v0.34.0
type Number struct {
// contains filtered or unexported fields
}
Number 模拟 TypeScript 的 number 类型,既可以表示整数也可以表示浮点数。 底层使用 float64 存储,这与 JS/TS 的实现机制一致。
func ParseNumber ¶ added in v0.34.0
ParseNumber 将字符串解析为 *Number。 它使用 strconv.ParseFloat,因此可以处理 "100" 和 "100.5" 两种情况。
Click to show internal directories.
Click to hide internal directories.