We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6326549 commit 6962ac7Copy full SHA for 6962ac7
1 file changed
config/config.go
@@ -97,7 +97,22 @@ func (c Config) CacheFile() string {
97
return path.Join(cacheDir, cacheFileName)
98
}
99
100
+func hasAccess(path string) bool {
101
+ status := true
102
+ file, err := os.Open(path)
103
+ if (err != nil) {
104
+ status = false
105
+ }
106
+ file.Close()
107
+ return status
108
+}
109
+
110
func checkAndCreateDir(path string) string {
111
+ isAccsessible := hasAccess(path)
112
+ if !isAccsessible {
113
+ fmt.Println("User isn't authorized to access the config file")
114
+ os.Exit(1)
115
116
if fileInfo, err := os.Stat(path); os.IsNotExist(err) || !fileInfo.IsDir() {
117
err := os.Mkdir(path, 0700)
118
if err != nil {
0 commit comments