mirror of
https://github.com/spf13/viper
synced 2025-05-10 22:27:18 +00:00
another lock
This commit is contained in:
parent
82dd6e2b2f
commit
9991524de0
1 changed files with 5 additions and 3 deletions
8
viper.go
8
viper.go
|
@ -551,8 +551,8 @@ func (v *Viper) providerPathExists(p *defaultRemoteProvider) bool {
|
||||||
// Returns nil if not found.
|
// Returns nil if not found.
|
||||||
// Note: This assumes that the path entries and map keys are lower cased.
|
// Note: This assumes that the path entries and map keys are lower cased.
|
||||||
func (v *Viper) searchMap(source map[string]interface{}, path []string) interface{} {
|
func (v *Viper) searchMap(source map[string]interface{}, path []string) interface{} {
|
||||||
//v.mu.RLock()
|
//v.mu.Lock()
|
||||||
//defer v.mu.RUnlock()
|
//defer v.mu.Unlock()
|
||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
return source
|
return source
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ func (v *Viper) searchMap(source map[string]interface{}, path []string) interfac
|
||||||
//
|
//
|
||||||
// Note: This assumes that the path entries and map keys are lower cased.
|
// Note: This assumes that the path entries and map keys are lower cased.
|
||||||
func (v *Viper) searchMapWithPathPrefixes(source map[string]interface{}, path []string) interface{} {
|
func (v *Viper) searchMapWithPathPrefixes(source map[string]interface{}, path []string) interface{} {
|
||||||
//v.mu.RLock()
|
//v.mu.Lock()
|
||||||
//defer v.mu.Unlock()
|
//defer v.mu.Unlock()
|
||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
return source
|
return source
|
||||||
|
@ -729,6 +729,8 @@ func GetViper() *Viper {
|
||||||
// Get returns an interface. For a specific value use one of the Get____ methods.
|
// Get returns an interface. For a specific value use one of the Get____ methods.
|
||||||
func Get(key string) interface{} { return v.Get(key) }
|
func Get(key string) interface{} { return v.Get(key) }
|
||||||
func (v *Viper) Get(key string) interface{} {
|
func (v *Viper) Get(key string) interface{} {
|
||||||
|
v.mu.Lock()
|
||||||
|
defer v.mu.Unlock()
|
||||||
lcaseKey := strings.ToLower(key)
|
lcaseKey := strings.ToLower(key)
|
||||||
val := v.find(lcaseKey, true)
|
val := v.find(lcaseKey, true)
|
||||||
if val == nil {
|
if val == nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue