Update go-homedir

parent f686b50c
......@@ -217,7 +217,7 @@
[[projects]]
name = "github.com/minio/go-homedir"
packages = ["."]
revision = "21304a94172ae3a09dee2cd86a12fb6f842138c7"
revision = "4d76aabb80b22bad8695d3904e943f1fb5e6199f"
[[projects]]
name = "github.com/minio/minio-go"
......
......@@ -229,8 +229,8 @@ ignored = ["test", "appengine"]
[[override]]
name = "github.com/minio/go-homedir"
revision = "21304a94172ae3a09dee2cd86a12fb6f842138c7"
revision = "4d76aabb80b22bad8695d3904e943f1fb5e6199f"
[[override]]
name = "github.com/opencontainers/runc"
revision = "94dc520a5732126985fec249f80c91b9e0601815"
......
......@@ -13,4 +13,4 @@ it has a cgo dependency on Darwin systems. This means that any Go code
that uses that package cannot cross compile. But 99% of the time the
use for `os/user` is just to retrieve the home directory, which we can
do for the current user without cgo. This library does that, enabling
cross-compilation.
cross-compilation.
// +build !windows
// Copyright 2016 (C) Mitchell Hashimoto
// Distributed under the MIT License.
package homedir
import (
......
// Copyright 2016 (C) Mitchell Hashimoto
// Distributed under the MIT License.
package homedir
import (
......
// Copyright 2016 (C) Mitchell Hashimoto
// Distributed under the MIT License.
// Package homedir implements a portable function to determine current user's homedir.
package homedir
......@@ -15,23 +12,25 @@ import (
var DisableCache bool
var homedirCache string
var cacheLock sync.Mutex
var cacheLock sync.RWMutex
// Dir returns the home directory for the executing user.
//
// This uses an OS-specific method for discovering the home directory.
// An error is returned if a home directory cannot be detected.
func Dir() (string, error) {
cacheLock.Lock()
defer cacheLock.Unlock()
// Return cached homedir if available.
if !DisableCache {
if homedirCache != "" {
return homedirCache, nil
cacheLock.RLock()
cached := homedirCache
cacheLock.RUnlock()
if cached != "" {
return cached, nil
}
}
cacheLock.Lock()
defer cacheLock.Unlock()
// Determine OS speific current homedir.
result, err := dir()
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment