object

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: EPL-1.0 Imports: 12 Imported by: 0

Documentation

Overview

Package object 用于将布尔值封装为并发安全的对象,提供一些基本的操作方法

Package object 用于将float32类型的数据封装为线程安全的对象

Package object 用于将float64类型的数据封装为线程安全的对象

Package object 用于将int32类型的数据封装为线程安全的对象

Package object 用于将int64类型的数据封装为线程安全的对象

Package object 用于将Map结构体封装为一个支持并发安全的泛型的键值对存储器

Package object 用于创建一个线程安全的字符串对象且提供对象的方法简易调用封装

Package object 将字符串切片封装为对象,提供线程安全的操作方法

Package object 将结构体切片封装为对象,提供线程安全的操作方法

Package object 用于将uint32类型的数据封装为线程安全的对象

Package object 用于将uint64类型的数据封装为线程安全的对象

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	Value bool // Value用于存储布尔值
	// contains filtered or unexported fields
}

Bool 类型包含一个布尔值和一个读写互斥锁

func (*Bool) Get

func (b *Bool) Get() bool

Get 方法返回Bool的Value

func (*Bool) IsFalse

func (b *Bool) IsFalse() bool

IsFalse 方法检查Bool的Value是否为false

func (*Bool) IsTrue

func (b *Bool) IsTrue() bool

IsTrue 方法检查Bool的Value是否为true

func (*Bool) LogicalAnd

func (b *Bool) LogicalAnd(value bool)

LogicalAnd 方法对Bool的Value执行逻辑与操作

func (*Bool) LogicalOr

func (b *Bool) LogicalOr(value bool)

LogicalOr 方法对Bool的Value执行逻辑或操作

func (*Bool) Set

func (b *Bool) Set(value bool)

Set 方法设置Bool的Value

func (*Bool) Toggle

func (b *Bool) Toggle()

Toggle 方法切换Bool的Value

type Float32

type Float32 interface {
	Set(value float32)         // 设置浮点数的值
	Get() float32              // 获取浮点数的值
	Add(delta float32) float32 // 增加浮点数的值
	String() string            // 将浮点数转换为字符串
}

Float32 接口定义了浮点数的基本操作

func NewNonThreadSafeFloat32

func NewNonThreadSafeFloat32(value float32) Float32

NewNonThreadSafeFloat32 函数创建一个新的非线程安全的Float32实例

func NewThreadSafeFloat32

func NewThreadSafeFloat32(value float32) Float32

NewThreadSafeFloat32 函数创建一个新的线程安全的Float32实例

type Float64

type Float64 interface {
	Set(value float64)         // 设置浮点数的值
	Get() float64              // 获取浮点数的值
	Add(delta float64) float64 // 增加浮点数的值
	String() string            // 将浮点数转换为字符串
}

Float64 接口定义了浮点数的基本操作

func NewNonThreadSafeFloat64

func NewNonThreadSafeFloat64(value float64) Float64

NewNonThreadSafeFloat64 函数创建一个新的非线程安全的Float64实例

func NewThreadSafeFloat64

func NewThreadSafeFloat64(value float64) Float64

NewThreadSafeFloat64 函数创建一个新的线程安全的Float64实例

type Int32

type Int32 interface {
	Set(value int32)       // 设置整数值
	Get() int32            // 获取当前整数值
	Add(delta int32) int32 // 增加值,并返回新值
	String() string        // 将整数转换为字符串
}

Int32 接口定义了整数的一组操作,包括设置、获取、增加值以及转换为字符串

func NewNonThreadSafeInt32

func NewNonThreadSafeInt32(value int32) Int32

NewNonThreadSafeInt32 函数创建并返回一个新的非线程安全的Int32实例

func NewThreadSafeInt32

func NewThreadSafeInt32(value int32) Int32

NewThreadSafeInt32 函数创建并返回一个新的线程安全的Int32实例

type Int64

type Int64 interface {
	Set(value int64)       // 设置整数值
	Get() int64            // 获取当前整数值
	Add(delta int64) int64 // 增加值,并返回新值
	String() string        // 将整数转换为字符串
}

Int64 接口定义了整数的一组操作,包括设置、获取、增加值以及转换为字符串

func NewNonThreadSafeInt64

func NewNonThreadSafeInt64(value int64) Int64

NewNonThreadSafeInt64 函数创建并返回一个新的非线程安全的Int64实例

func NewThreadSafeInt64

func NewThreadSafeInt64(value int64) Int64

NewThreadSafeInt64 函数创建并返回一个新的线程安全的Int64实例

type Map

type Map[K comparable, V any] struct {
	Value map[K]V // 存储实际的键值对
	// contains filtered or unexported fields
}

Map 是一个泛型映射,提供键值对的存储,以及并发控制

func NewMap

func NewMap[K comparable, V any](threadSafe bool) *Map[K, V]

NewMap 创建一个新的Map实例,根据threadSafe参数决定是否线程安全

func (*Map[K, V]) Add

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

Add 方法添加一个键值对,如果键已存在,返回false

func (*Map[K, V]) Clean

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

Clean 方法清空Map中所有键值对

func (*Map[K, V]) Clone

func (m *Map[K, V]) Clone(threadSafe bool) (*Map[K, V], error)

Clone 方法克隆一个Map,可选择是否线程安全

func (*Map[K, V]) Contains

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

Contains 方法检查Map中是否含有指定的键

func (*Map[K, V]) Delete

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

Delete 方法删除一个键值对,如果键不存在,返回false

func (*Map[K, V]) Entries

func (m *Map[K, V]) Entries() map[K]V

Entries 方法返回Map中所有的键值对

func (*Map[K, V]) Equals

func (m *Map[K, V]) Equals(m2 *Map[K, V]) (bool, error)

Equals 方法判断两个Map是否相等

func (*Map[K, V]) ForEach

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

ForEach 方法遍历Map,对每个键值对执行callback函数

func (*Map[K, V]) Get

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

Get 方法获取一个键对应的值

func (*Map[K, V]) IsEmpty

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

IsEmpty 方法检查Map是否为空

func (*Map[K, V]) Keys

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

Keys 方法返回Map中所有的键

func (*Map[K, V]) Merge

func (m *Map[K, V]) Merge(m2 *Map[K, V], keepOldValue bool)

Merge 方法合并另一个Map到当前Map中,keepOldValue决定是否保留旧值

func (*Map[K, V]) Set added in v1.0.6

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

Set 方法设置一个键对应的值,如果键不存在则新建,如果存在则更新

func (*Map[K, V]) Size

func (m *Map[K, V]) Size() int

Size 方法返回Map中键值对的数量

func (*Map[K, V]) Update

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

Update 方法更新一个键对应的值,如果键不存在,返回false

func (*Map[K, V]) Values

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

Values 方法返回Map中所有的值

type NonThreadSafeFloat32

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

NonThreadSafeFloat32 结构体提供非线程安全的浮点数操作

func (*NonThreadSafeFloat32) Add

func (ntsf *NonThreadSafeFloat32) Add(delta float32) float32

Add 方法直接增加浮点数的值

func (*NonThreadSafeFloat32) Get

func (ntsf *NonThreadSafeFloat32) Get() float32

Get 方法直接获取浮点数的值

func (*NonThreadSafeFloat32) Set

func (ntsf *NonThreadSafeFloat32) Set(value float32)

Set 方法直接设置浮点数的值

func (*NonThreadSafeFloat32) String

func (ntsf *NonThreadSafeFloat32) String() string

String 方法将浮点数转换为字符串

type NonThreadSafeFloat64

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

NonThreadSafeFloat64 结构体提供非线程安全的浮点数操作

func (*NonThreadSafeFloat64) Add

func (ntsf *NonThreadSafeFloat64) Add(delta float64) float64

Add 方法直接增加浮点数的值

func (*NonThreadSafeFloat64) Get

func (ntsf *NonThreadSafeFloat64) Get() float64

Get 方法直接获取浮点数的值

func (*NonThreadSafeFloat64) Set

func (ntsf *NonThreadSafeFloat64) Set(value float64)

Set 方法直接设置浮点数的值

func (*NonThreadSafeFloat64) String

func (ntsf *NonThreadSafeFloat64) String() string

String 方法将浮点数转换为字符串

type NonThreadSafeInt32

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

NonThreadSafeInt32 结构体提供一个非线程安全的整数类型

func (*NonThreadSafeInt32) Add

func (nts *NonThreadSafeInt32) Add(delta int32) int32

Add 方法直接增加整数值,并返回新值,非线程安全

func (*NonThreadSafeInt32) Get

func (nts *NonThreadSafeInt32) Get() int32

Get 方法直接获取当前整数值,非线程安全

func (*NonThreadSafeInt32) Set

func (nts *NonThreadSafeInt32) Set(value int32)

Set 方法直接设置整数值,非线程安全

func (*NonThreadSafeInt32) String

func (nts *NonThreadSafeInt32) String() string

String 方法返回当前整数值的字符串表示,非线程安全

type NonThreadSafeInt64

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

NonThreadSafeInt64 结构体提供一个非线程安全的整数类型

func (*NonThreadSafeInt64) Add

func (nts *NonThreadSafeInt64) Add(delta int64) int64

Add 方法直接增加整数值,并返回新值,非线程安全

func (*NonThreadSafeInt64) Get

func (nts *NonThreadSafeInt64) Get() int64

Get 方法直接获取当前整数值,非线程安全

func (*NonThreadSafeInt64) Set

func (nts *NonThreadSafeInt64) Set(value int64)

Set 方法直接设置整数值,非线程安全

func (*NonThreadSafeInt64) String

func (nts *NonThreadSafeInt64) String() string

String 方法返回当前整数值的字符串表示,非线程安全

type NonThreadSafeUInt32

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

NonThreadSafeUInt32 结构体包含一个无符号32位整型数值,非线程安全

func (*NonThreadSafeUInt32) Add

func (nts *NonThreadSafeUInt32) Add(delta uint32) uint32

Add 方法直接增加数值,并返回新值,非线程安全

func (*NonThreadSafeUInt32) Get

func (nts *NonThreadSafeUInt32) Get() uint32

Get 方法直接获取数值,非线程安全

func (*NonThreadSafeUInt32) Set

func (nts *NonThreadSafeUInt32) Set(value uint32)

Set 方法直接设置数值,非线程安全

func (*NonThreadSafeUInt32) String

func (nts *NonThreadSafeUInt32) String() string

String 方法将数值转换为其十进制的字符串表示形式,非线程安全

type NonThreadSafeUInt64

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

NonThreadSafeUInt64 结构体包含一个无符号64位整型数值,非线程安全

func (*NonThreadSafeUInt64) Add

func (nts *NonThreadSafeUInt64) Add(delta uint64) uint64

Add 方法直接增加数值,并返回新值,非线程安全

func (*NonThreadSafeUInt64) Get

func (nts *NonThreadSafeUInt64) Get() uint64

Get 方法直接获取数值,非线程安全

func (*NonThreadSafeUInt64) Set

func (nts *NonThreadSafeUInt64) Set(value uint64)

Set 方法直接设置数值,非线程安全

func (*NonThreadSafeUInt64) String

func (nts *NonThreadSafeUInt64) String() string

String 方法将数值转换为其十进制的字符串表示形式,非线程安全

type String

type String struct {
	Value string // 存储字符串的变量
	// contains filtered or unexported fields
}

String 结构体,用于存储单个字符串及其锁

func NewString

func NewString(value string, threadSafe bool) *String

NewString 函数创建一个String对象,可以选择是否启用线程安全

func (*String) Concat

func (s *String) Concat(value string) *String

Concat 方法将给定的字符串连接到String对象上

func (*String) Contains

func (s *String) Contains(value string) bool

Contains 方法检查String是否包含给定的字符串

func (*String) Count

func (s *String) Count(substr string) int

Count 方法返回String中某子串出现的次数

func (*String) Display

func (s *String) Display()

Display 方法打印String的值

func (*String) DisplayType

func (s *String) DisplayType()

DisplayType 方法打印String的类型

func (*String) Equal

func (s *String) Equal(value string) bool

Equal 方法比较String的值和给定的字符串是否相等

func (*String) EqualFold

func (s *String) EqualFold(value string) bool

EqualFold 方法在不区分大小写的情况下比较String的值和给定字符串是否相同

func (*String) Fields

func (s *String) Fields() []string

Fields 方法按照空白符分割String的值,并返回一个切片

func (*String) Get

func (s *String) Get() string

Get 方法返回String的值

func (*String) HasPrefix

func (s *String) HasPrefix(prefix string) bool

HasPrefix 方法检查String的值是否有指定的前缀

func (*String) HasSuffix

func (s *String) HasSuffix(suffix string) bool

HasSuffix 方法检查String的值是否有指定的后缀

func (*String) Index

func (s *String) Index(substr string) int

Index 方法返回子串在String中首次出现的索引值,如果没有则返回-1

func (*String) IsEmpty

func (s *String) IsEmpty() bool

IsEmpty 方法检查String是否为空

func (*String) LastIndex

func (s *String) LastIndex(substr string) int

LastIndex 方法返回子串在String中最后一次出现的索引值,如果没有则返回-1

func (*String) Length

func (s *String) Length() int

Length 方法返回String值的长度

func (*String) Repeat

func (s *String) Repeat(n int) string

Repeat 方法返回String值重复n次后的新字符串

func (*String) Replace

func (s *String) Replace(old, new string, n int) string

Replace 方法在String值中将old子串替换为new子串,最多替换n个;如果n<0,则替换所有old子串

func (*String) Set

func (s *String) Set(value string)

Set 方法设置String的值,如果新值与旧值相同,则不进行操作

func (*String) Split

func (s *String) Split(sep string) []string

Split 方法将String的值按照sep分割,并返回一个字符串切片

func (*String) ToLower

func (s *String) ToLower() string

ToLower 方法返回String值的小写形式

func (*String) ToUpper

func (s *String) ToUpper() string

ToUpper 方法返回String值的大写形式

func (*String) Trim

func (s *String) Trim(cutset string) string

Trim 方法返回去掉String两侧指定字符集合的新字符串

func (*String) TrimSpace

func (s *String) TrimSpace() string

TrimSpace 方法返回去掉String两侧空白符的新字符串

type StringSlice

type StringSlice struct {
	Values []string // 存储实际的字符串切片数据
	// contains filtered or unexported fields
}

StringSlice 结构体,用于存储字符串切片,并通过locker来控制线程安全

func NewStringSlice

func NewStringSlice(values []string, threadSafe bool) *StringSlice

NewStringSlice 函数创建StringSlice实例,可以选择是否线程安全

func (*StringSlice) Add

func (s *StringSlice) Add(item string)

Add 方法向切片中添加一个元素

func (*StringSlice) AppendWithoutDuplicates

func (s *StringSlice) AppendWithoutDuplicates(newItems []string)

AppendWithoutDuplicates 方法将新元素添加到切片中,同时确保没有重复

func (*StringSlice) Clean

func (s *StringSlice) Clean()

Clean 方法清空切片

func (*StringSlice) Clone

func (s *StringSlice) Clone(threadSafe bool) *StringSlice

Clone 方法创建并返回一个当前副本

func (*StringSlice) Contains

func (s *StringSlice) Contains(keyword string) bool

Contains 方法判断切片中是否包含关键字

func (*StringSlice) ExactMatch

func (s *StringSlice) ExactMatch(keyword string) bool

ExactMatch 方法判断切片中是否有元素与关键字完全匹配

func (*StringSlice) Get

func (s *StringSlice) Get() []string

Get 方法获取切片的值

func (*StringSlice) Remove

func (s *StringSlice) Remove(value string, allowChangeOrder bool)

Remove 方法根据值移除元素

func (*StringSlice) RemoveAtIndex

func (s *StringSlice) RemoveAtIndex(index int, allowChangeOrder bool)

RemoveAtIndex 方法根据索引移除元素

func (*StringSlice) RemoveAtIndices

func (s *StringSlice) RemoveAtIndices(indices []int, allowChangeOrder bool)

RemoveAtIndices 方法根据一组索引移除多个元素

func (*StringSlice) RemoveIfContains

func (s *StringSlice) RemoveIfContains(keyword string)

RemoveIfContains 方法移除切片中包含关键字的元素

func (*StringSlice) RemoveIfNotContains

func (s *StringSlice) RemoveIfNotContains(keyword string)

RemoveIfNotContains 方法移除切片中不包含关键字的元素

func (*StringSlice) Search

func (s *StringSlice) Search(keyword string) map[int]string

Search 方法返回包含关键字的所有元素及其索引

func (*StringSlice) Set

func (s *StringSlice) Set(values []string)

Set 方法设置切片的值

func (*StringSlice) Size

func (s *StringSlice) Size() int

Size 方法返回切片的长度

type Struct added in v1.0.3

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

Struct 是一个泛型结构体,提供并发控制

func (*Struct[T]) Clone added in v1.0.3

func (s *Struct[T]) Clone() (*Struct[T], error)

Clone 方法深度拷贝结构体

func (*Struct[T]) Get added in v1.0.3

func (s *Struct[T]) Get() T

Get 方法获取结构体的值

func (*Struct[T]) Set added in v1.0.3

func (s *Struct[T]) Set(value T)

Set 方法设置结构体的值

type StructSlice added in v1.0.4

type StructSlice[T any] struct {
	Values []T // 存储实际的字符串切片数据
	// contains filtered or unexported fields
}

StructSlice 结构体,用于存储字符串切片,并通过locker来控制线程安全

func NewStructSlice added in v1.0.4

func NewStructSlice[T any](values []T, threadSafe bool) *StructSlice[T]

NewStructSlice 函数创建StructSlice实例,可以选择是否线程安全

func (*StructSlice[T]) Add added in v1.0.4

func (s *StructSlice[T]) Add(item T)

Add 方法向切片中添加一个元素

func (*StructSlice[T]) Clean added in v1.0.4

func (s *StructSlice[T]) Clean()

Clean 方法清空切片

func (*StructSlice[T]) Clone added in v1.0.4

func (s *StructSlice[T]) Clone(threadSafe bool) *StructSlice[T]

Clone 方法克隆切片

func (*StructSlice[T]) Get added in v1.0.4

func (s *StructSlice[T]) Get() []T

Get 方法获取切片的值

func (*StructSlice[T]) RemoveAtIndex added in v1.0.4

func (s *StructSlice[T]) RemoveAtIndex(index int, allowChangeOrder bool)

RemoveAtIndex 方法移除指定索引的元素

func (*StructSlice[T]) RemoveAtIndices added in v1.0.4

func (s *StructSlice[T]) RemoveAtIndices(indices []int, allowChangeOrder bool)

RemoveAtIndices 方法根据一组索引移除多个元素

func (*StructSlice[T]) Set added in v1.0.4

func (s *StructSlice[T]) Set(values []T)

Set 方法设置切片的值

func (*StructSlice[T]) Size added in v1.0.4

func (s *StructSlice[T]) Size() int

Size 方法获取切片的大小

type ThreadSafeFloat32

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

ThreadSafeFloat32 结构体提供了线程安全的浮点数操作

func (*ThreadSafeFloat32) Add

func (tsf *ThreadSafeFloat32) Add(delta float32) float32

Add 方法使用原子操作安全地增加浮点数的值

func (*ThreadSafeFloat32) Get

func (tsf *ThreadSafeFloat32) Get() float32

Get 方法使用原子操作安全地获取浮点数的值

func (*ThreadSafeFloat32) Set

func (tsf *ThreadSafeFloat32) Set(value float32)

Set 方法使用原子操作安全地设置浮点数的值

func (*ThreadSafeFloat32) String

func (tsf *ThreadSafeFloat32) String() string

String 方法将浮点数转换为字符串

type ThreadSafeFloat64

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

ThreadSafeFloat64 结构体提供了线程安全的浮点数操作

func (*ThreadSafeFloat64) Add

func (tsf *ThreadSafeFloat64) Add(delta float64) float64

Add 方法使用原子操作安全地增加浮点数的值

func (*ThreadSafeFloat64) Get

func (tsf *ThreadSafeFloat64) Get() float64

Get 方法使用原子操作安全地获取浮点数的值

func (*ThreadSafeFloat64) Set

func (tsf *ThreadSafeFloat64) Set(value float64)

Set 方法使用原子操作安全地设置浮点数的值

func (*ThreadSafeFloat64) String

func (tsf *ThreadSafeFloat64) String() string

String 方法将浮点数转换为字符串

type ThreadSafeInt32

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

ThreadSafeInt32 结构体提供一个线程安全的整数类型

func (*ThreadSafeInt32) Add

func (tsi *ThreadSafeInt32) Add(delta int32) int32

Add 方法使用原子操作来安全地增加整数值,并返回新值

func (*ThreadSafeInt32) Get

func (tsi *ThreadSafeInt32) Get() int32

Get 方法使用原子操作来安全地获取当前整数值

func (*ThreadSafeInt32) Set

func (tsi *ThreadSafeInt32) Set(value int32)

Set 方法使用原子操作来安全地设置整数值

func (*ThreadSafeInt32) String

func (tsi *ThreadSafeInt32) String() string

String 方法返回当前整数值的字符串表示

type ThreadSafeInt64

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

ThreadSafeInt64 结构体提供一个线程安全的整数类型

func (*ThreadSafeInt64) Add

func (tsi *ThreadSafeInt64) Add(delta int64) int64

Add 方法使用原子操作来安全地增加整数值,并返回新值

func (*ThreadSafeInt64) Get

func (tsi *ThreadSafeInt64) Get() int64

Get 方法使用原子操作来安全地获取当前整数值

func (*ThreadSafeInt64) Set

func (tsi *ThreadSafeInt64) Set(value int64)

Set 方法使用原子操作来安全地设置整数值

func (*ThreadSafeInt64) String

func (tsi *ThreadSafeInt64) String() string

String 方法返回当前整数值的字符串表示

type ThreadSafeUInt32

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

ThreadSafeUInt32 结构体包含一个无符号32位整型数值,确保线程安全

func (*ThreadSafeUInt32) Add

func (tsi *ThreadSafeUInt32) Add(delta uint32) uint32

Add 方法使用原子操作增加数值,并返回新值

func (*ThreadSafeUInt32) Get

func (tsi *ThreadSafeUInt32) Get() uint32

Get 方法使用原子操作获取数值

func (*ThreadSafeUInt32) Set

func (tsi *ThreadSafeUInt32) Set(value uint32)

Set 方法使用原子操作设置数值

func (*ThreadSafeUInt32) String

func (tsi *ThreadSafeUInt32) String() string

String 方法将数值转换为其十进制的字符串表示形式

type ThreadSafeUInt64

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

ThreadSafeUInt64 结构体包含一个无符号64位整型数值,确保线程安全

func (*ThreadSafeUInt64) Add

func (tsi *ThreadSafeUInt64) Add(delta uint64) uint64

Add 方法使用原子操作增加数值,并返回新值

func (*ThreadSafeUInt64) Get

func (tsi *ThreadSafeUInt64) Get() uint64

Get 方法使用原子操作获取数值

func (*ThreadSafeUInt64) Set

func (tsi *ThreadSafeUInt64) Set(value uint64)

Set 方法使用原子操作设置数值

func (*ThreadSafeUInt64) String

func (tsi *ThreadSafeUInt64) String() string

String 方法将数值转换为其十进制的字符串表示形式

type Time added in v1.0.2

type Time struct {
	Value time.Time // 存储时间值
	// contains filtered or unexported fields
}

Time 结构体用于存储时间值和关联的锁

func NewTime added in v1.0.2

func NewTime(value time.Time, threadSafe bool) *Time

NewTime 函数创建一个Time实例,可选是否启用线程安全

func (*Time) Add added in v1.0.2

func (t *Time) Add(d time.Duration) time.Time

Add 方法为Time增加指定的时间间隔

func (*Time) AddDate added in v1.0.2

func (t *Time) AddDate(years int, months int, days int) time.Time

AddDate 方法为Time增加指定的年月日

func (*Time) After added in v1.0.2

func (t *Time) After(u time.Time) bool

After 方法判断Time是否在另一个时间u之后

func (*Time) AppendFormat added in v1.0.2

func (t *Time) AppendFormat(b []byte, layout string) []byte

AppendFormat 方法将Time按照指定的格式追加到字节切片b中

func (*Time) AsTime added in v1.0.2

func (t *Time) AsTime() time.Time

AsTime 方法返回Time的time.Time表示形式

func (*Time) Before added in v1.0.2

func (t *Time) Before(u time.Time) bool

Before 方法判断Time是否在另一个时间u之前

func (*Time) Clock added in v1.0.2

func (t *Time) Clock() (hour, min, sec int)

Clock 方法返回Time的时钟表示

func (*Time) Date added in v1.0.2

func (t *Time) Date() (year int, month time.Month, day int)

Date 方法返回Time的日期表示

func (*Time) Day added in v1.0.2

func (t *Time) Day() int

Day 方法返回Time的日期部分

func (*Time) Equal added in v1.0.2

func (t *Time) Equal(u time.Time) bool

Equal 方法判断两个Time是否相同

func (*Time) Format added in v1.0.2

func (t *Time) Format(layout string) string

Format 方法将Time格式化为字符串

func (*Time) Get added in v1.0.2

func (t *Time) Get() time.Time

Get 方法返回Time的当前值

func (*Time) GobDecode added in v1.0.2

func (t *Time) GobDecode(data []byte) error

GobDecode 方法实现gob.Decoder接口,从传输形式中还原时间

func (*Time) GobEncode added in v1.0.2

func (t *Time) GobEncode() ([]byte, error)

GobEncode 方法实现gob.Encoder接口,将时间转换为适合传输的形式

func (*Time) Hour added in v1.0.2

func (t *Time) Hour() int

Hour 方法返回Time的小时部分

func (*Time) ISOWeek added in v1.0.2

func (t *Time) ISOWeek() (year, week int)

ISOWeek 方法返回Time所在的ISO周数

func (*Time) In added in v1.0.2

func (t *Time) In(loc *time.Location) time.Time

In 方法将Time转换为指定时区的时间

func (*Time) IsZero added in v1.0.2

func (t *Time) IsZero() bool

IsZero 方法判断Time是否为零值

func (*Time) Local added in v1.0.2

func (t *Time) Local() time.Time

Local 方法将Time转换为本地时区的时间

func (*Time) Location added in v1.0.2

func (t *Time) Location() *time.Location

Location 方法返回Time的地点信息

func (*Time) MarshalBinary added in v1.0.2

func (t *Time) MarshalBinary() ([]byte, error)

MarshalBinary 方法将Time编码为二进制形式

func (*Time) MarshalJSON added in v1.0.2

func (t *Time) MarshalJSON() ([]byte, error)

MarshalJSON 方法将Time编码为JSON格式

func (*Time) MarshalText added in v1.0.2

func (t *Time) MarshalText() ([]byte, error)

MarshalText 方法将Time编码为文本格式

func (*Time) Minute added in v1.0.2

func (t *Time) Minute() int

Minute 方法返回Time的分钟部分

func (*Time) Month added in v1.0.2

func (t *Time) Month() time.Month

Month 方法返回Time的月份部分

func (*Time) Nanosecond added in v1.0.2

func (t *Time) Nanosecond() int

Nanosecond 方法返回Time的纳秒部分

func (*Time) Round added in v1.0.2

func (t *Time) Round(d time.Duration) time.Time

Round 方法将Time舍入到最接近的时间间隔

func (*Time) Second added in v1.0.2

func (t *Time) Second() int

Second 方法返回Time的秒部分

func (*Time) Set added in v1.0.2

func (t *Time) Set(value time.Time)

Set 方法设置Time的值

func (*Time) Since added in v1.0.2

func (t *Time) Since() time.Duration

Since 方法返回从Time到现在的时间间隔

func (*Time) String added in v1.0.2

func (t *Time) String() string

String 方法返回Time的字符串表示形式

func (*Time) Sub added in v1.0.2

func (t *Time) Sub(u time.Time) time.Duration

Sub 方法返回Time和另一个时间u之间的间隔

func (*Time) Truncate added in v1.0.2

func (t *Time) Truncate(d time.Duration) time.Time

Truncate 方法将Time截断到之前的最近时间间隔

func (*Time) UTC added in v1.0.2

func (t *Time) UTC() time.Time

UTC 方法将Time转换为UTC时区的时间

func (*Time) Unix added in v1.0.2

func (t *Time) Unix() int64

Unix 方法返回Time的Unix时间戳(秒)

func (*Time) UnixMicro added in v1.0.2

func (t *Time) UnixMicro() int64

UnixMicro 方法返回Time的Unix时间戳(微秒)

func (*Time) UnixMilli added in v1.0.2

func (t *Time) UnixMilli() int64

UnixMilli 方法返回Time的Unix时间戳(毫秒)

func (*Time) UnixNano added in v1.0.2

func (t *Time) UnixNano() int64

UnixNano 方法返回Time的Unix时间戳(纳秒)

func (*Time) UnmarshalBinary added in v1.0.2

func (t *Time) UnmarshalBinary(data []byte) error

UnmarshalBinary 方法从二进制格式解码Time

func (*Time) UnmarshalJSON added in v1.0.2

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON 方法从JSON格式解码Time

func (*Time) UnmarshalText added in v1.0.2

func (t *Time) UnmarshalText(data []byte) error

UnmarshalText 方法从文本格式解码Time

func (*Time) Until added in v1.0.2

func (t *Time) Until() time.Duration

Until 方法返回从现在到Time的时间间隔

func (*Time) Weekday added in v1.0.2

func (t *Time) Weekday() time.Weekday

Weekday 方法返回Time的星期表示

func (*Time) Year added in v1.0.2

func (t *Time) Year() int

Year 方法返回Time的年份部分

func (*Time) YearDay added in v1.0.2

func (t *Time) YearDay() int

YearDay 方法返回Time在该年中的天数

func (*Time) Zone added in v1.0.2

func (t *Time) Zone() (zone string, offset int)

Zone 方法返回Time的时区和时区偏移量

type UInt32

type UInt32 interface {
	Set(value uint32)        // 设置数值
	Get() uint32             // 获取数值
	Add(delta uint32) uint32 // 对数值进行原子增加操作
	String() string          // 获取数值的字符串表示形式
}

UInt32 接口声明了一组操作无符号32位整型的方法

func NewNonThreadSafeUInt32

func NewNonThreadSafeUInt32(value uint32) UInt32

NewNonThreadSafeUInt32 函数创建一个新的非线程安全的无符号32位整型数值

func NewThreadSafeUInt32

func NewThreadSafeUInt32(value uint32) UInt32

NewThreadSafeUInt32 函数创建一个新的线程安全的无符号32位整型数值

type UInt64

type UInt64 interface {
	Set(value uint64)        // 设置数值
	Get() uint64             // 获取数值
	Add(delta uint64) uint64 // 对数值进行原子增加操作
	String() string          // 获取数值的字符串表示形式
}

UInt64 接口声明了一组操作无符号64位整型的方法

func NewNonThreadSafeUInt64

func NewNonThreadSafeUInt64(value uint64) UInt64

NewNonThreadSafeUInt64 函数创建一个新的非线程安全的无符号64位整型数值

func NewThreadSafeUInt64

func NewThreadSafeUInt64(value uint64) UInt64

NewThreadSafeUInt64 函数创建一个新的线程安全的无符号64位整型数值

Jump to

Keyboard shortcuts

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