Skip to content

Commit 2e0af06

Browse files
authored
Merge pull request #241 from shiftstack/minor
Minor changes
2 parents d291cd6 + aecae7e commit 2e0af06

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.22
55
require (
66
github.com/gofrs/uuid/v5 v5.3.0
77
github.com/gophercloud/gophercloud/v2 v2.4.0
8-
github.com/mitchellh/go-homedir v1.1.0
98
golang.org/x/sys v0.28.0
109
golang.org/x/text v0.21.0
1110
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk=
22
github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
33
github.com/gophercloud/gophercloud/v2 v2.4.0 h1:XhP5tVEH3ni66NSNK1+0iSO6kaGPH/6srtx6Cr+8eCg=
44
github.com/gophercloud/gophercloud/v2 v2.4.0/go.mod h1:uJWNpTgJPSl2gyzJqcU/pIAhFUWvIkp8eE8M15n9rs4=
5-
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
6-
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
75
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
86
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
97
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=

internal/util.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"fmt"
8-
"io/ioutil"
98
"os"
9+
"os/user"
10+
"path/filepath"
1011
"reflect"
1112
"strings"
12-
13-
"github.com/mitchellh/go-homedir"
1413
)
1514

1615
// RemainingKeys will inspect a struct and compare it to a map. Any struct
@@ -92,15 +91,20 @@ func pathOrContents(poc string) ([]byte, bool, error) {
9291

9392
path := poc
9493
if path[0] == '~' {
95-
var err error
96-
path, err = homedir.Expand(path)
94+
usr, err := user.Current()
9795
if err != nil {
9896
return []byte(path), true, err
9997
}
98+
99+
if len(path) == 1 {
100+
path = usr.HomeDir
101+
} else if strings.HasPrefix(path, "~/") {
102+
path = filepath.Join(usr.HomeDir, path[2:])
103+
}
100104
}
101105

102106
if _, err := os.Stat(path); err == nil {
103-
contents, err := ioutil.ReadFile(path)
107+
contents, err := os.ReadFile(path)
104108
if err != nil {
105109
return contents, true, err
106110
}

0 commit comments

Comments
 (0)