Skip to content

Commit

Permalink
file.go use filepath.Dir()
Browse files Browse the repository at this point in the history
  • Loading branch information
stokito committed Nov 26, 2020
1 parent 948e7cc commit 4e44c9d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions config/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"fmt"
"os"
"path/filepath"
"regexp"
"strings"

Expand Down Expand Up @@ -81,7 +82,7 @@ func Write() (path string, err error) {
return path, err
}

cfgdir := basedir(path)
cfgdir := filepath.Dir(path)
// create config dir if not exist
if _, err := os.Stat(cfgdir); err != nil {
err = os.MkdirAll(cfgdir, 0755)
Expand Down Expand Up @@ -141,8 +142,3 @@ func xdgSupport() bool {
}
return false
}

func basedir(path string) string {
parts := strings.Split(path, "/")
return strings.Join((parts[0 : len(parts)-1]), "/")
}

0 comments on commit 4e44c9d

Please sign in to comment.