/
paths.go
45 lines (37 loc) · 979 Bytes
/
paths.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package config
import (
"os"
"syscall"
"go.uber.org/zap"
)
const (
// FolderPerm holds the default permission mask for folders
FolderPerm = 0700
// FilePerm holds the default permission mask for files
FilePerm = 0644
)
var (
// configPath stores the absolute path of the config directory
configPath string
// CachePath stores the absolute path of the cache directory
CachePath string
)
// initDirectories attempts to create cache and config directories
func initDirectories() {
home, err := os.UserHomeDir()
if err != nil {
Logger.Warn("failed to get users home directory", zap.Error(err))
return
}
configPath = home + "/.config/trakx/"
CachePath = home + "/.cache/trakx/"
syscall.Umask(0)
err = os.MkdirAll(CachePath, FolderPerm)
if err != nil {
Logger.Warn("failed to create cache directory", zap.Error(err))
}
err = os.MkdirAll(configPath, FolderPerm)
if err != nil {
Logger.Warn("failed to create config directory", zap.Error(err))
}
}