From 4e44c9d5f768145bd5aba2d3d71e65e281f9a90c Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Thu, 26 Nov 2020 12:08:55 +0200 Subject: [PATCH] file.go use filepath.Dir() --- config/file.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config/file.go b/config/file.go index b8851e4..6282fd1 100644 --- a/config/file.go +++ b/config/file.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "path/filepath" "regexp" "strings" @@ -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) @@ -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]), "/") -}