utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Singleton

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

Singleton 泛型单例封装

func NewSingleton

func NewSingleton[T any](initFunc func() T) *Singleton[T]

NewSingleton 创建单例 initFunc: 初始化函数,返回实例

func (*Singleton[T]) Get

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

Get 获取单例实例(延迟初始化)

func (*Singleton[T]) IsInitialized

func (s *Singleton[T]) IsInitialized() bool

IsInitialized 检查是否已初始化

func (*Singleton[T]) Reset

func (s *Singleton[T]) Reset()

Reset 重置单例(主要用于测试)

Jump to

Keyboard shortcuts

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