diff --git a/go.mod b/go.mod index a91756e..da7855a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.22 require ( github.com/gofrs/uuid/v5 v5.3.0 github.com/gophercloud/gophercloud/v2 v2.4.0 - github.com/mitchellh/go-homedir v1.1.0 golang.org/x/sys v0.28.0 golang.org/x/text v0.21.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 3029d89..bc56535 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk= github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= github.com/gophercloud/gophercloud/v2 v2.4.0 h1:XhP5tVEH3ni66NSNK1+0iSO6kaGPH/6srtx6Cr+8eCg= github.com/gophercloud/gophercloud/v2 v2.4.0/go.mod h1:uJWNpTgJPSl2gyzJqcU/pIAhFUWvIkp8eE8M15n9rs4= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= diff --git a/internal/util.go b/internal/util.go index 887bb8f..029c701 100644 --- a/internal/util.go +++ b/internal/util.go @@ -5,12 +5,11 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "io/ioutil" "os" + "os/user" + "path/filepath" "reflect" "strings" - - "github.com/mitchellh/go-homedir" ) // RemainingKeys will inspect a struct and compare it to a map. Any struct @@ -92,15 +91,20 @@ func pathOrContents(poc string) ([]byte, bool, error) { path := poc if path[0] == '~' { - var err error - path, err = homedir.Expand(path) + usr, err := user.Current() if err != nil { return []byte(path), true, err } + + if len(path) == 1 { + path = usr.HomeDir + } else if strings.HasPrefix(path, "~/") { + path = filepath.Join(usr.HomeDir, path[2:]) + } } if _, err := os.Stat(path); err == nil { - contents, err := ioutil.ReadFile(path) + contents, err := os.ReadFile(path) if err != nil { return contents, true, err }