mirror of https://github.com/docker/docs.git
Use pure-go library to get user home directory.
Fixes #194. Signed-off-by: Joe Beda <joe.github@bedafamily.com>
This commit is contained in:
parent
87b1b2efbc
commit
f7d0ea70af
|
@ -3,11 +3,11 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
|
@ -37,14 +37,11 @@ func parseConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if trustDir == "" {
|
if trustDir == "" {
|
||||||
// Retrieve current user to get home directory
|
|
||||||
usr, err := user.Current()
|
|
||||||
if err != nil {
|
|
||||||
fatalf("cannot get current user: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get home directory for current user
|
// Get home directory for current user
|
||||||
homeDir := usr.HomeDir
|
homeDir, err := homedir.Dir()
|
||||||
|
if err != nil {
|
||||||
|
fatalf("cannot get current user home directory: %v", err)
|
||||||
|
}
|
||||||
if homeDir == "" {
|
if homeDir == "" {
|
||||||
fatalf("cannot get current user home directory")
|
fatalf("cannot get current user home directory")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue