lang

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatDate     = "yyyy-MM-dd"
	FormatTime     = "HH:mm:ss"
	FormatDatetime = FormatDate + " " + FormatTime
)

Variables

This section is empty.

Functions

func DateFormat

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

DateFormat 函数用于将时间格式化为指定的字符串格式

func DateParse

func DateParse(dateStr string, format string) (time.Time, error)

DateParse 函数用于解析指定格式的日期字符串

Types

type Date

type Date struct {
	// contains filtered or unexported fields
}

func DateNew

func DateNew(time time.Time) *Date

func DateNow

func DateNow() *Date

func DateStr

func DateStr(time string, format string) (*Date, error)

DateStr time: 时间 eg: 2024-14-12 12:15:20 format: 时间格式 eg: yyyy-MM-dd HH:mm:ss OR FormatDatetime

func (*Date) CompareTimes

func (t *Date) CompareTimes(time time.Time) int

func (*Date) OffsetDay

func (t *Date) OffsetDay(offset int) *Date

OffsetDay 函数增加或减少指定的天数

func (*Date) OffsetHour

func (t *Date) OffsetHour(offset int) *Date

OffsetHour 函数增加或减少指定的小时数

func (*Date) OffsetMinute

func (t *Date) OffsetMinute(offset int) *Date

OffsetMinute 函数增加或减少指定的分钟数

func (*Date) OffsetMonth

func (t *Date) OffsetMonth(offset int) *Date

OffsetMonth 函数增加或减少指定的月数

func (*Date) OffsetSecond

func (t *Date) OffsetSecond(offset int) *Date

OffsetSecond 函数增加或减少指定的秒数

func (*Date) OffsetYear

func (t *Date) OffsetYear(offset int) *Date

OffsetYear 函数增加或减少指定的年数

func (*Date) ToString

func (t *Date) ToString(format string) string

type Iterator

type Iterator[T any] struct {
	// contains filtered or unexported fields
}

func IteratorNew

func IteratorNew[T any](list *List[T], lock *sync.RWMutex) *Iterator[T]

func (*Iterator[T]) HasNext

func (it *Iterator[T]) HasNext() bool

func (*Iterator[T]) Next

func (it *Iterator[T]) Next() (*T, error)

type KeyValue

type KeyValue[K comparable, V any] struct {
	Key   K
	Value V
}

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

func ListNew

func ListNew[T any]() List[T]

func (*List[T]) Add

func (l *List[T]) Add(element T)

Add 添加元素到List

func (*List[T]) AddAll

func (l *List[T]) AddAll(element []T)

AddAll 添加元素到List

func (*List[T]) Clear

func (l *List[T]) Clear()

Clear 清空List

func (*List[T]) Get

func (l *List[T]) Get(index int) (*T, error)

Get 获取指定位置的元素

func (*List[T]) Iterator

func (l *List[T]) Iterator() *Iterator[T]

func (*List[T]) Remove

func (l *List[T]) Remove(index int) error

Remove 删除指定位置的元素

func (*List[T]) Size

func (l *List[T]) Size() int

Size 返回List的大小

type Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func MapNew

func MapNew[K comparable, V any]() *Map[K, V]

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear()

func (*Map[K, V]) ContainKey

func (m *Map[K, V]) ContainKey(key K) bool

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) (V, error)

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() []K

func (*Map[K, V]) Put

func (m *Map[K, V]) Put(key K, value V)

func (*Map[K, V]) Remove

func (m *Map[K, V]) Remove(key K)

Jump to

Keyboard shortcuts

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