config

package
v1.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration interface {
	// 基本设置和获取
	Set(path string, value interface{})
	Get(path string) interface{}

	// 类型安全的获取方法
	GetString(path string) string
	GetStringWithDefault(path, defaultValue string) string
	GetInt(path string) int
	GetIntWithDefault(path string, defaultValue int) int
	GetLong(path string) int64
	GetLongWithDefault(path string, defaultValue int64) int64
	GetBool(path string) bool
	GetBoolWithDefault(path string, defaultValue bool) bool

	// 复合类型获取
	GetList(path string) []interface{}
	GetStringList(path string) []string
	GetStringArray(path string) []string
	GetMap(path string) map[string]interface{}

	// 嵌套配置
	GetConfiguration(path string) Configuration
	GetListConfiguration(path string) []Configuration

	// 工具方法
	ToJSON() (string, error)
	Clone() Configuration
	IsExists(path string) bool
}

Configuration 配置管理接口 - 纯接口定义,不包含实现

func FromFile

func FromFile(filename string) (Configuration, error)

func FromJSON

func FromJSON(jsonStr string) (Configuration, error)

func NewConfiguration

func NewConfiguration() Configuration

func NewConfigurationFromMap

func NewConfigurationFromMap(data map[string]interface{}) Configuration

type ConfigurationFactory

type ConfigurationFactory interface {
	CreateConfiguration() Configuration
	CreateConfigurationFromMap(data map[string]interface{}) Configuration
	FromJSON(jsonStr string) (Configuration, error)
	FromFile(filename string) (Configuration, error)
}

ConfigurationFactory 配置工厂接口

func NewConfigurationFactory

func NewConfigurationFactory() ConfigurationFactory

type DefaultConfiguration

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

DefaultConfiguration 默认配置实现

func (*DefaultConfiguration) Clone

func (*DefaultConfiguration) Get

func (c *DefaultConfiguration) Get(path string) interface{}

func (*DefaultConfiguration) GetBool

func (c *DefaultConfiguration) GetBool(path string) bool

func (*DefaultConfiguration) GetBoolWithDefault

func (c *DefaultConfiguration) GetBoolWithDefault(path string, defaultValue bool) bool

func (*DefaultConfiguration) GetConfiguration

func (c *DefaultConfiguration) GetConfiguration(path string) Configuration

func (*DefaultConfiguration) GetInt

func (c *DefaultConfiguration) GetInt(path string) int

func (*DefaultConfiguration) GetIntWithDefault

func (c *DefaultConfiguration) GetIntWithDefault(path string, defaultValue int) int

func (*DefaultConfiguration) GetList

func (c *DefaultConfiguration) GetList(path string) []interface{}

func (*DefaultConfiguration) GetListConfiguration

func (c *DefaultConfiguration) GetListConfiguration(path string) []Configuration

func (*DefaultConfiguration) GetLong

func (c *DefaultConfiguration) GetLong(path string) int64

func (*DefaultConfiguration) GetLongWithDefault

func (c *DefaultConfiguration) GetLongWithDefault(path string, defaultValue int64) int64

func (*DefaultConfiguration) GetMap

func (c *DefaultConfiguration) GetMap(path string) map[string]interface{}

func (*DefaultConfiguration) GetString

func (c *DefaultConfiguration) GetString(path string) string

func (*DefaultConfiguration) GetStringArray

func (c *DefaultConfiguration) GetStringArray(path string) []string

func (*DefaultConfiguration) GetStringList

func (c *DefaultConfiguration) GetStringList(path string) []string

func (*DefaultConfiguration) GetStringWithDefault

func (c *DefaultConfiguration) GetStringWithDefault(path, defaultValue string) string

func (*DefaultConfiguration) IsExists

func (c *DefaultConfiguration) IsExists(path string) bool

func (*DefaultConfiguration) Set

func (c *DefaultConfiguration) Set(path string, value interface{})

func (*DefaultConfiguration) ToJSON

func (c *DefaultConfiguration) ToJSON() (string, error)

type DefaultConfigurationFactory

type DefaultConfigurationFactory struct{}

DefaultConfigurationFactory 默认配置工厂实现

func (*DefaultConfigurationFactory) CreateConfiguration

func (f *DefaultConfigurationFactory) CreateConfiguration() Configuration

func (*DefaultConfigurationFactory) CreateConfigurationFromMap

func (f *DefaultConfigurationFactory) CreateConfigurationFromMap(data map[string]interface{}) Configuration

func (*DefaultConfigurationFactory) FromFile

func (f *DefaultConfigurationFactory) FromFile(filename string) (Configuration, error)

func (*DefaultConfigurationFactory) FromJSON

func (f *DefaultConfigurationFactory) FromJSON(jsonStr string) (Configuration, error)

Jump to

Keyboard shortcuts

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