Floating up the error seems like a best practice. Part of #7
@ -65,8 +65,10 @@ func InitApp() {
cobra.CheckErr(err)
}
var app = model.NewApp(cfg.DbPath)
App = &TApp{&app, &cfg}
var app, err = model.NewApp(cfg.DbPath)
App = &TApp{app, &cfg}
var fmt_str = "%-10s %-20s %s\n"
@ -20,12 +20,12 @@ type App struct {
*db.DbCtx
func NewApp(db_path string) App {
func NewApp(db_path string) (*App, error) {
app, err := db.Init(db_path)
if err != nil {
log.Fatal(err.Error())
return nil, err
return App{app}
return &App{app}, nil