summaryrefslogtreecommitdiff
path: root/pkg/utils.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-05-01 16:23:08 +0200
committerJulien Dessaux2024-05-01 16:23:08 +0200
commit8b9195e3e3506d576b39a23ca646c260dfacc808 (patch)
tree1cdbdd2fb368654ef8eab702258eb5d6a90e1447 /pkg/utils.go
parentchore(gonf): fix go vet and staticcheck errors (diff)
downloadgonf-8b9195e3e3506d576b39a23ca646c260dfacc808.tar.gz
gonf-8b9195e3e3506d576b39a23ca646c260dfacc808.tar.bz2
gonf-8b9195e3e3506d576b39a23ca646c260dfacc808.zip
chore(gonf): fix errcheck and shadow errors
Diffstat (limited to 'pkg/utils.go')
-rw-r--r--pkg/utils.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/pkg/utils.go b/pkg/utils.go
index c3301f2..3920737 100644
--- a/pkg/utils.go
+++ b/pkg/utils.go
@@ -28,15 +28,19 @@ func FilterSlice[T any](slice *[]T, predicate func(T) bool) {
func makeDirectoriesHierarchy(dir string, perms *Permissions) (Status, error) {
if _, err := os.Lstat(dir); err != nil {
if errors.Is(err, fs.ErrNotExist) {
- if status, err := makeDirectoriesHierarchy(filepath.Dir(dir), perms); err != nil {
- return status, err
+ if _, err = makeDirectoriesHierarchy(filepath.Dir(dir), perms); err != nil {
+ return BROKEN, err
+ }
+ var m int
+ if m, err = perms.mode.Int(); err != nil {
+ return BROKEN, err
+ }
+ if err = os.Mkdir(dir, fs.FileMode(m)); err != nil {
+ return BROKEN, err
}
- m, err := perms.mode.Int()
- if err != nil {
+ if _, err = perms.resolve(dir); err != nil {
return BROKEN, err
}
- os.Mkdir(dir, fs.FileMode(m))
- perms.resolve(dir)
return REPAIRED, nil
} else {
return BROKEN, err