-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
55 lines (43 loc) · 1 KB
/
config.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
46
47
48
49
50
51
52
53
54
55
package go_util
import (
"fmt"
"os"
)
type Dirs struct {
HomeDir string
AnkorDir string
ConfigDir string
OptDir string
BinDir string
TmpDir string
}
func NewDirs() Dirs {
userHomeDir, _ := os.UserHomeDir()
return Dirs{
HomeDir: userHomeDir,
}
}
func (d *Dirs) GetHomeDir() string {
return d.HomeDir
}
func (d *Dirs) GetAnkorDir() string {
return fmt.Sprintf("%s/.%s", d.GetHomeDir(), AppName)
}
func (d *Dirs) GetConfigDir() string {
return fmt.Sprintf("%s/.%s/etc", d.GetHomeDir(), AppName)
}
func (d *Dirs) GetOptDir() string {
return fmt.Sprintf("%s/.%s/opt", d.GetHomeDir(), AppName)
}
func (d *Dirs) GetBinDir() string {
return fmt.Sprintf("%s/.%s/bin", d.GetHomeDir(), AppName)
}
func (d *Dirs) GetTmpDir() string {
return fmt.Sprintf("%s/.%s/tmp", d.GetHomeDir(), AppName)
}
func (d *Dirs) GetPluginsDir() string {
return fmt.Sprintf("%s/.%s/plugins", d.GetHomeDir(), AppName)
}
func (d *Dirs) GetLogsDir() string {
return fmt.Sprintf("%s/.%s/logs", d.GetHomeDir(), AppName)
}