gutils

package
v1.2.16 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	YYYY_MM_DD_HH_MM_SS = "2006-01-02 15:04:05"
	YYYY_MM_DD          = "2006-01-02"
	MM_DD               = "01-02"
	YYYY                = "2006"
	YYYYMMDD            = "20060102"
	YYYYMM              = "200601"
	MMDD                = "0102"

	DayDuration = 24 * time.Hour
)

Variables

This section is empty.

Functions

func CamelToSnakeCase

func CamelToSnakeCase(input string) string

CamelToSnakeCase 将驼峰命名转换为蛇形

func CopyMap

func CopyMap[K comparable, V any](m map[K]V) map[K]V

func CreateDir

func CreateDir(dir string) error

func FileExists

func FileExists(filepath string) bool

FileExists 检查文件是否存在

func FirstLetterToLower

func FirstLetterToLower(s string) string

func FirstLetterToUpper

func FirstLetterToUpper(s string) string

FirstLetterToUpper 首字母大写

func GetDate

func GetDate(offset int) string

func GetFileExtension

func GetFileExtension(name string) string

GetFileExtension 获取文件扩展名

func GetLastDay

func GetLastDay() string

func GetLastMonthRange

func GetLastMonthRange() (string, string)

func GetLastWeekRange

func GetLastWeekRange() (string, string)

GetLastWeekRange 获取上周的起始和结束日期,如 20230824, 20230830

func GetLastYearRange

func GetLastYearRange() (string, string)

func GetMonth

func GetMonth(offset int) string

func GetMonthRange

func GetMonthRange(offset int) (string, string)

GetMonthRange 获取指定偏移月的起始日期和结束日期,如 20230901, 20230930 offset: 相对于当前月的偏移量,0 表示当前月,-1 表示上个月,1 表示下个月

func GetThisMonthRange

func GetThisMonthRange() (string, string)

func GetThisWeekRange

func GetThisWeekRange() (string, string)

GetThisWeekRange 获取本周的起始和结束日期,如 20230901, 20230907

func GetThisYearRange

func GetThisYearRange() (string, string)

func GetToday

func GetToday() string

func GetWeekRange

func GetWeekRange(offset int) (string, string)

GetWeekRange 获取本周的起始和结束日期,返回示例:20230901, 20230907 offset: 0 表示本周,-7 表示上周

func GetYear

func GetYear(offset int) string

func GetYearRange

func GetYearRange(offset int) (string, string)

func LinkedListToArray

func LinkedListToArray(l *list.List, dest any) error

func PathExists

func PathExists(path string) (bool, error)

func ReplaceIdToID

func ReplaceIdToID(str string) string

ReplaceIdToID 将id、Id、iD替换为Id

func SliceContain

func SliceContain[T comparable](slice []T, element T) bool

func SliceDiff

func SliceDiff[T comparable](a, b []T) []T

SliceDiff 返回在 a 中但不在 b 中的元素

func SliceDuplicate

func SliceDuplicate[T comparable](s []T) []T

func SnakeToLowerCamel

func SnakeToLowerCamel(s string) string

SnakeToLowerCamel 蛇形转小驼峰

func SnakeToPascal

func SnakeToPascal(s string) string

SnakeToPascal 蛇形转大驼峰

func TimeFormat

func TimeFormat(t time.Time, format string) string

func ToJsonString

func ToJsonString(v any) string

func ToString

func ToString(v any) string

func Trim

func Trim(str string) string

func TrimFileExtension

func TrimFileExtension(name string) string

TrimFileExtension 去除文件扩展名

func VToFloat64

func VToFloat64(v any) float64

func VToInt64

func VToInt64(v any) int64

func VToUint64

func VToUint64(v any) uint64

Types

type TreeNode

type TreeNode struct {
	ID       int // 节点的唯一标识符
	ParentID int // 节点的父节点的唯一标识符
	TreeNodeData
	Children []*TreeNode // 节点的子节点
}

TreeNode 结构体表示树的一个节点

func BuildTree

func BuildTree(nodes []TreeNode) []*TreeNode

BuildTree 从节点列表构建树

type TreeNodeData

type TreeNodeData any

Jump to

Keyboard shortcuts

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