realize/config/utils.go

28 lines
392 B
Go
Raw Normal View History

2016-10-21 13:59:11 +00:00
package config
import (
"log"
"os"
"path/filepath"
)
2016-10-21 15:30:12 +00:00
func (c *Config) Wdir() string {
2016-10-21 13:59:11 +00:00
dir, err := os.Getwd()
2016-10-21 15:30:12 +00:00
c.Validate(err)
2016-10-21 13:59:11 +00:00
return filepath.Base(dir)
}
2016-10-21 15:30:12 +00:00
func (c *Config) Validate(err error) error {
2016-10-21 13:59:11 +00:00
if err != nil {
2016-10-21 15:30:12 +00:00
log.Fatal(Red(err))
2016-10-21 13:59:11 +00:00
}
return nil
}
2016-10-21 15:30:12 +00:00
func (c *Config) Fatal(msg string, err error){
if(msg != "") {
log.Fatal(Red(msg), err.Error())
}
log.Fatal(err.Error())
}