From 551e3f029a42ade9ebe19098038e65ca379aef12 Mon Sep 17 00:00:00 2001 From: sqshq Date: Sun, 4 Aug 2019 00:24:05 -0400 Subject: [PATCH] fix user home directory for linux to work on both ubuntu and centos, without loosing cross-compilation support --- go.mod | 1 + go.sum | 2 ++ metadata/storage.go | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 919f76a..60293a7 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/lunixbochs/vtclean v1.0.0 github.com/mattn/go-runewidth v0.0.4 github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22 ) diff --git a/go.sum b/go.sum index 214a5a5..d4d2ab0 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,8 @@ github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/ github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea h1:mQncVDBpKkAecPcH2IMGpKUQYhwowlafQbfkz2QFqkc= github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea/go.mod h1:QzTGLGoOqLHUBK8/EZ0v4Fa4CdyXmdyRwCHcl0YbeO4= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= diff --git a/metadata/storage.go b/metadata/storage.go index 602d3da..e5ff71f 100644 --- a/metadata/storage.go +++ b/metadata/storage.go @@ -1,6 +1,7 @@ package metadata import ( + "github.com/mitchellh/go-homedir" "io/ioutil" "log" "os" @@ -28,7 +29,7 @@ func getPlatformStoragePath(filename string) string { cache, _ := os.UserCacheDir() return filepath.Join(cache, windowsDir, filename) default: - home, _ := os.UserHomeDir() + home, _ := homedir.Dir() return filepath.Join(home, linuxDir, filename) } }