hrm/os_darwin.go

32 lines
581 B
Go
Raw Normal View History

2019-10-23 18:29:13 -04:00
package main
import (
"log"
"os"
"os/user"
"path"
)
var confDir string
2019-11-22 16:44:26 -05:00
var fontSize float32 = 16
2019-10-23 18:29:13 -04:00
2019-10-28 12:46:57 -04:00
func getConfDir() string {
if confDir != "" {
return confDir
}
2019-10-23 18:29:13 -04:00
usr, err := user.Current()
if err != nil {
log.Fatal("Cannot get current user: ", err)
}
confDir = path.Join(usr.HomeDir, ".config/gohrm")
if _, err := os.Stat(confDir); os.IsNotExist(err) {
err = os.MkdirAll(confDir, 0700)
if err != nil {
log.Fatal("Cannot create configuration directory %s: %s", confDir, err)
} else {
log.Print("Configuration directory created")
}
}
2019-10-28 12:46:57 -04:00
return confDir
2019-10-23 18:29:13 -04:00
}