39 lines
720 B
Go
39 lines
720 B
Go
|
//+build !darwin
|
||
|
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"os/user"
|
||
|
"path"
|
||
|
|
||
|
"golang.org/x/image/font/gofont/goregular"
|
||
|
"golang.org/x/image/font/sfnt"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
regular *sfnt.Font
|
||
|
confDir string
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
regular, err = sfnt.Parse(goregular.TTF)
|
||
|
if err != nil {
|
||
|
log(Fatal, "Cannot parse default font: ", err)
|
||
|
}
|
||
|
usr, err := user.Current()
|
||
|
if err != nil {
|
||
|
log(Fatal, "Cannot get current user: ", err)
|
||
|
}
|
||
|
confDir = path.Join(usr.HomeDir, ".config/passgo")
|
||
|
if _, err := os.Stat(confDir); os.IsNotExist(err) {
|
||
|
err = os.MkdirAll(confDir, 0700)
|
||
|
if err != nil {
|
||
|
log(Info, "Cannot create configuration directory ", confDir)
|
||
|
log(Fatal, err)
|
||
|
} else {
|
||
|
log(Info, "Configuration directory created")
|
||
|
}
|
||
|
}
|
||
|
}
|