Documentation
¶
Index ¶
- type Configuration
- type ConfigurationFactory
- type DefaultConfiguration
- func (c *DefaultConfiguration) Clone() Configuration
- func (c *DefaultConfiguration) Get(path string) interface{}
- func (c *DefaultConfiguration) GetBool(path string) bool
- func (c *DefaultConfiguration) GetBoolWithDefault(path string, defaultValue bool) bool
- func (c *DefaultConfiguration) GetConfiguration(path string) Configuration
- func (c *DefaultConfiguration) GetInt(path string) int
- func (c *DefaultConfiguration) GetIntWithDefault(path string, defaultValue int) int
- func (c *DefaultConfiguration) GetList(path string) []interface{}
- func (c *DefaultConfiguration) GetListConfiguration(path string) []Configuration
- func (c *DefaultConfiguration) GetLong(path string) int64
- func (c *DefaultConfiguration) GetLongWithDefault(path string, defaultValue int64) int64
- func (c *DefaultConfiguration) GetMap(path string) map[string]interface{}
- func (c *DefaultConfiguration) GetString(path string) string
- func (c *DefaultConfiguration) GetStringArray(path string) []string
- func (c *DefaultConfiguration) GetStringList(path string) []string
- func (c *DefaultConfiguration) GetStringWithDefault(path, defaultValue string) string
- func (c *DefaultConfiguration) IsExists(path string) bool
- func (c *DefaultConfiguration) Set(path string, value interface{})
- func (c *DefaultConfiguration) ToJSON() (string, error)
- type DefaultConfigurationFactory
- func (f *DefaultConfigurationFactory) CreateConfiguration() Configuration
- func (f *DefaultConfigurationFactory) CreateConfigurationFromMap(data map[string]interface{}) Configuration
- func (f *DefaultConfigurationFactory) FromFile(filename string) (Configuration, error)
- func (f *DefaultConfigurationFactory) FromJSON(jsonStr string) (Configuration, error)
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 (c *DefaultConfiguration) Clone() Configuration
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)
Click to show internal directories.
Click to hide internal directories.