realize/settings/utils.go
2016-12-17 11:43:27 +01:00

31 lines
559 B
Go

package settings
import (
"log"
"os"
"path/filepath"
)
// Wdir return the current working directory
func (s Settings) Wdir() string {
dir, err := os.Getwd()
s.Validate(err)
return filepath.Base(dir)
}
// Validate checks a fatal error
func (s Settings) Validate(err error) error {
if err != nil {
s.Fatal(err, "")
}
return nil
}
// Fatal prints a fatal error with its additional messages
func (s Settings) Fatal(err error, msg ...interface{}) {
if len(msg) > 0 {
log.Fatalln(s.Red.Regular(msg...), err.Error())
}
log.Fatalln(err.Error())
}