mirror of
https://github.com/taigrr/jety.git
synced 2026-04-01 19:08:58 -07:00
clarify readme, extract setters
This commit is contained in:
16
README.md
16
README.md
@@ -6,18 +6,4 @@ This is a package for collapsing multiple configuration stores (env+json, env+ya
|
||||
|
||||
It should behave similarly to the AutomaticEnv functionality of viper, but without some of the extra heft of the depedendencies it carries.
|
||||
|
||||
|
||||
.AutomaticEnv
|
||||
.ConfigFileUsed
|
||||
.GetDuration
|
||||
.GetString
|
||||
.GetStringMap
|
||||
.GetStringSlice
|
||||
.ReadInConfig
|
||||
.SetConfigFile
|
||||
.SetConfigName
|
||||
.SetConfigType
|
||||
.SetDefault
|
||||
.Set("privkey", string
|
||||
viper.ConfigFileNotFoundError); ok {
|
||||
.WriteConfig
|
||||
The inital purpose of this repo is to support the configuration requirements of [grlx](http://github.com/gogrlx/grlx), but development may continue to expand until more viper use cases and functionality are covered.
|
||||
|
||||
14
env.go
14
env.go
@@ -273,20 +273,6 @@ func (c *ConfigManager) SetEnvPrefix(prefix string) {
|
||||
c.envPrefix = prefix
|
||||
}
|
||||
|
||||
func (c *ConfigManager) Set(key string, value any) {
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.mapConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) SetDefault(key string, value any) {
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.defaultConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) GetIntSlice(key string) []int {
|
||||
c.mutex.RLock()
|
||||
defer c.mutex.RUnlock()
|
||||
|
||||
33
setters.go
Normal file
33
setters.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (c *ConfigManager) SetBool(key string, value bool) {
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.mapConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) SetString(key string, value string) {
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.mapConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) Set(key string, value any) {
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.mapConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
func (c *ConfigManager) SetDefault(key string, value any) {
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
lower := strings.ToLower(key)
|
||||
c.defaultConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
Reference in New Issue
Block a user