Documentation
¶
Index ¶
- Constants
- Variables
- func ExpandConfigEnvValue(targetValue interface{}) (interface{}, bool)
- func ExpandConfigNestedValue(targetValue interface{}) (interface{}, bool)
- func ExpandConfigValueIfNecessary(targetValue interface{}) interface{}
- func GetActiveProfiles() []string
- func Load(opts ...Option) error
- func LoadConfigByPrefix(prefix string, configStructPtr interface{}) error
- func SetConfig(yamlBytes []byte) error
- type AnyMap
- type Config
- type Option
- func AddProperty(key string, value interface{}) Option
- func WithAbsPath(absPath ...string) Option
- func WithConfigName(configName string) Option
- func WithConfigType(configType string) Option
- func WithMergeDepth(mergeDepth uint8) Option
- func WithProfilesActive(profilesActive ...string) Option
- func WithSearchPath(searchPath ...string) Option
- type Options
Constants ¶
View Source
const ( YmlExtension = "yml" YamlExtension = "yaml" DefaultSearchConfigName = "config" DefaultSearchConfigType = YamlExtension // yaml SearchPathEnvKey = "IOC_GOLANG_CONFIG_SEARCH_PATH" TypeEnvKey = "IOC_GOLANG_CONFIG_TYPE" NameEnvKey = "IOC_GOLANG_CONFIG_NAME" ActiveProfileEnvKey = "IOC_GOLANG_CONFIG_ACTIVE_PROFILE" YamlConfigSeparator = "." EnvValueSeparator = "," )
View Source
const ( EnvPrefixKey = "${" EnvSuffixKey = "}" And = "&" )
View Source
const (
PathSeparator = string(os.PathSeparator)
)
Variables ¶
View Source
var (
DefaultSearchPath = []string{".", "./config", "./configs"}
)
Functions ¶
func ExpandConfigEnvValue ¶
func ExpandConfigEnvValue(targetValue interface{}) (interface{}, bool)
func ExpandConfigNestedValue ¶
func ExpandConfigNestedValue(targetValue interface{}) (interface{}, bool)
func ExpandConfigValueIfNecessary ¶
func ExpandConfigValueIfNecessary(targetValue interface{}) interface{}
func GetActiveProfiles ¶ added in v1.0.1
func GetActiveProfiles() []string
func LoadConfigByPrefix ¶
LoadConfigByPrefix prefix is like 'a.b.c' or 'a.b.<github.com/xxx/xx/xxx.Impl>.c', configStructPtr is interface ptr
Types ¶
type Option ¶
type Option func(opts *Options)
func AddProperty ¶
func WithAbsPath ¶
func WithConfigName ¶
func WithConfigType ¶
func WithMergeDepth ¶
func WithProfilesActive ¶
func WithSearchPath ¶
type Options ¶
type Options struct {
AbsPath []string // abs path -> high level priority
// default: config
ConfigName string
// default: yaml
ConfigType string
// Search path of config files
//
// default: ., ./config, ./configs;
//
// priority: ./ > ./config > ./configs
SearchPath []string
// Profiles active
//
// default: []string
//
// e.g.:
//
// []string{"dev","share"}
//
// search target: config.yml/config_dev.yml/config_share.yml
ProfilesActive []string
// Depth of merging under multiple config files
MergeDepth uint8
// Properties set by API
Properties AnyMap
}
Click to show internal directories.
Click to hide internal directories.