27 lines
486 B
Go
27 lines
486 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"os"
|
||
|
"os/user"
|
||
|
"path"
|
||
|
)
|
||
|
|
||
|
var confDir string
|
||
|
|
||
|
func init() {
|
||
|
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")
|
||
|
}
|
||
|
}
|
||
|
}
|