utils

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorText added in v0.2.5

func ColorText(code string, text interface{}) string

ColorText 根據環境支持自動決定是否添加顏色到文本 code 是 ANSI 顏色代碼,text 是要設置顏色的文本

func CompareAny added in v0.2.5

func CompareAny(a, b any) int

CompareAny compares two values of any type and returns: -1 if a < b

0 if a == b
1 if a > b

It uses type ranking and type-specific comparison logic.

func ConvertDateFormat added in v0.2.4

func ConvertDateFormat(pattern string) string

ConvertDateFormat 將常見的日期格式模式轉換為 Go 語言的時間格式

func FormatValue added in v0.2.5

func FormatValue(value any) string

FormatValue 根據值的類型格式化輸出,改善顯示效果

func GetTypeSortingRank added in v0.2.5

func GetTypeSortingRank(v any) int

GetTypeSortingRank returns the type rank for sorting mixed types. Lower rank means higher priority (comes first in ascending order).

func ParseColIndex

func ParseColIndex(colIndex string) int

func ToFloat64 added in v0.2.5

func ToFloat64(v any) float64

ToFloat64 converts any numeric value to float64.

func ToFloat64Safe added in v0.2.5

func ToFloat64Safe(v any) (float64, bool)

ToFloat64Safe tries to convert any numeric value to float64 and returns a boolean indicating success.

func TruncateString added in v0.2.5

func TruncateString(s string, maxLength int) string

TruncateString 截斷字符串到指定寬度,太長的字符串末尾加上省略號,使用 runewidth 計算字元寬度

Types

type F64orRat added in v0.2.5

type F64orRat interface {
	float64 | *big.Rat
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL