summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/minio/go-homedir
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/minio/go-homedir')
-rw-r--r--vendor/github.com/minio/go-homedir/LICENSE21
-rw-r--r--vendor/github.com/minio/go-homedir/README.md16
-rw-r--r--vendor/github.com/minio/go-homedir/dir_posix.go64
-rw-r--r--vendor/github.com/minio/go-homedir/dir_windows.go28
-rw-r--r--vendor/github.com/minio/go-homedir/homedir.go68
-rw-r--r--vendor/github.com/minio/go-homedir/homedir_test.go114
6 files changed, 0 insertions, 311 deletions
diff --git a/vendor/github.com/minio/go-homedir/LICENSE b/vendor/github.com/minio/go-homedir/LICENSE
deleted file mode 100644
index f9c841a51..000000000
--- a/vendor/github.com/minio/go-homedir/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2013 Mitchell Hashimoto
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/vendor/github.com/minio/go-homedir/README.md b/vendor/github.com/minio/go-homedir/README.md
deleted file mode 100644
index 085f57775..000000000
--- a/vendor/github.com/minio/go-homedir/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# go-homedir
-
-This is a Go library for detecting the user's home directory without
-the use of cgo, so the library can be used in cross-compilation environments.
-
-Usage is incredibly simple, just call `homedir.Dir()` to get the home directory
-for a user, and `homedir.Expand()` to expand the `~` in a path to the home
-directory.
-
-**Why not just use `os/user`?** The built-in `os/user` package is not
-available on certain architectures such as i386 or PNaCl. Additionally
-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.
diff --git a/vendor/github.com/minio/go-homedir/dir_posix.go b/vendor/github.com/minio/go-homedir/dir_posix.go
deleted file mode 100644
index 4615fe063..000000000
--- a/vendor/github.com/minio/go-homedir/dir_posix.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// +build !windows
-
-// Copyright 2016 (C) Mitchell Hashimoto
-// Distributed under the MIT License.
-
-package homedir
-
-import (
- "bytes"
- "errors"
- "os"
- "os/exec"
- "os/user"
- "strconv"
- "strings"
-)
-
-// dir returns the homedir of current user for all POSIX compatible
-// operating systems.
-func dir() (string, error) {
- // First prefer the HOME environmental variable
- if home := os.Getenv("HOME"); home != "" {
- return home, nil
- }
-
- // user.Current is not implemented for i386 and PNaCL like environments.
- if currUser, err := user.Current(); err == nil {
- return currUser.HomeDir, nil
- }
-
- // If that fails, try getent
- var stdout bytes.Buffer
- cmd := exec.Command("getent", "passwd", strconv.Itoa(os.Getuid()))
- cmd.Stdout = &stdout
- if err := cmd.Run(); err != nil {
- // If "getent" is missing, ignore it
- if err != exec.ErrNotFound {
- return "", err
- }
- } else {
- if passwd := strings.TrimSpace(stdout.String()); passwd != "" {
- // username:password:uid:gid:gecos:home:shell
- passwdParts := strings.SplitN(passwd, ":", 7)
- if len(passwdParts) > 5 {
- return passwdParts[5], nil
- }
- }
- }
-
- // If all else fails, try the shell
- stdout.Reset()
- cmd = exec.Command("sh", "-c", "cd && pwd")
- cmd.Stdout = &stdout
- if err := cmd.Run(); err != nil {
- return "", err
- }
-
- result := strings.TrimSpace(stdout.String())
- if result == "" {
- return "", errors.New("blank output when reading home directory")
- }
-
- return result, nil
-}
diff --git a/vendor/github.com/minio/go-homedir/dir_windows.go b/vendor/github.com/minio/go-homedir/dir_windows.go
deleted file mode 100644
index 85e5218c7..000000000
--- a/vendor/github.com/minio/go-homedir/dir_windows.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2016 (C) Mitchell Hashimoto
-// Distributed under the MIT License.
-
-package homedir
-
-import (
- "errors"
- "os"
-)
-
-// dir returns the homedir of current user for MS Windows OS.
-func dir() (string, error) {
- // First prefer the HOME environmental variable
- if home := os.Getenv("HOME"); home != "" {
- return home, nil
- }
- drive := os.Getenv("HOMEDRIVE")
- path := os.Getenv("HOMEPATH")
- home := drive + path
- if drive == "" || path == "" {
- home = os.Getenv("USERPROFILE")
- }
- if home == "" {
- return "", errors.New("HOMEDRIVE, HOMEPATH, and USERPROFILE are blank")
- }
-
- return home, nil
-}
diff --git a/vendor/github.com/minio/go-homedir/homedir.go b/vendor/github.com/minio/go-homedir/homedir.go
deleted file mode 100644
index 092373801..000000000
--- a/vendor/github.com/minio/go-homedir/homedir.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2016 (C) Mitchell Hashimoto
-// Distributed under the MIT License.
-
-// Package homedir implements a portable function to determine current user's homedir.
-package homedir
-
-import (
- "errors"
- "path/filepath"
- "sync"
-)
-
-// DisableCache will disable caching of the home directory. Caching is enabled
-// by default.
-var DisableCache bool
-
-var homedirCache string
-var cacheLock sync.Mutex
-
-// 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
- }
- }
-
- // Determine OS speific current homedir.
- result, err := dir()
- if err != nil {
- return "", err
- }
-
- // Cache for future lookups.
- homedirCache = result
- return result, nil
-}
-
-// Expand expands the path to include the home directory if the path
-// is prefixed with `~`. If it isn't prefixed with `~`, the path is
-// returned as-is.
-func Expand(path string) (string, error) {
- if len(path) == 0 {
- return path, nil
- }
-
- if path[0] != '~' {
- return path, nil
- }
-
- if len(path) > 1 && path[1] != '/' && path[1] != '\\' {
- return "", errors.New("cannot expand user-specific home dir")
- }
-
- dir, err := Dir()
- if err != nil {
- return "", err
- }
-
- return filepath.Join(dir, path[1:]), nil
-}
diff --git a/vendor/github.com/minio/go-homedir/homedir_test.go b/vendor/github.com/minio/go-homedir/homedir_test.go
deleted file mode 100644
index a45121ff1..000000000
--- a/vendor/github.com/minio/go-homedir/homedir_test.go
+++ /dev/null
@@ -1,114 +0,0 @@
-package homedir
-
-import (
- "os"
- "os/user"
- "path/filepath"
- "testing"
-)
-
-func patchEnv(key, value string) func() {
- bck := os.Getenv(key)
- deferFunc := func() {
- os.Setenv(key, bck)
- }
-
- os.Setenv(key, value)
- return deferFunc
-}
-
-func BenchmarkDir(b *testing.B) {
- // We do this for any "warmups"
- for i := 0; i < 10; i++ {
- Dir()
- }
-
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- Dir()
- }
-}
-
-func TestDir(t *testing.T) {
- // NOTE: This test is not portable. If user.Current() worked
- // everywhere, we wouldn't need our package in the first place.
- u, err := user.Current()
- if err != nil {
- t.Fatalf("err: %s", err)
- }
-
- dir, err := Dir()
- if err != nil {
- t.Fatalf("err: %s", err)
- }
-
- if u.HomeDir != dir {
- t.Fatalf("%#v != %#v", u.HomeDir, dir)
- }
-}
-
-func TestExpand(t *testing.T) {
- u, err := user.Current()
- if err != nil {
- t.Fatalf("err: %s", err)
- }
-
- cases := []struct {
- Input string
- Output string
- Err bool
- }{
- {
- "/foo",
- "/foo",
- false,
- },
-
- {
- "~/foo",
- filepath.Join(u.HomeDir, "foo"),
- false,
- },
-
- {
- "",
- "",
- false,
- },
-
- {
- "~",
- u.HomeDir,
- false,
- },
-
- {
- "~foo/foo",
- "",
- true,
- },
- }
-
- for _, tc := range cases {
- actual, err := Expand(tc.Input)
- if (err != nil) != tc.Err {
- t.Fatalf("Input: %#v\n\nErr: %s", tc.Input, err)
- }
-
- if actual != tc.Output {
- t.Fatalf("Input: %#v\n\nOutput: %#v", tc.Input, actual)
- }
- }
-
- DisableCache = true
- defer func() { DisableCache = false }()
- defer patchEnv("HOME", "/custom/path/")()
- expected := filepath.Join("/", "custom", "path", "foo/bar")
- actual, err := Expand("~/foo/bar")
-
- if err != nil {
- t.Errorf("No error is expected, got: %v", err)
- } else if actual != expected {
- t.Errorf("Expected: %v; actual: %v", expected, actual)
- }
-}