Beispiel #1
0
func (jm *JobManager) initDB() {
	u, err := user.Current()
	if err != nil {
		panic(err)
	}
	myConfig, err := config.NewConfig(fmt.Sprintf("%s/.waparc", u.HomeDir))
	if err != nil {
		panic(err)
	}
	user := myConfig.DBuser
	pass := myConfig.DBpass
	host := myConfig.DBhost
	port := myConfig.DBport
	dbname := myConfig.DBname

	if jm.mydb != nil && jm.mydb.db != nil {
		// all set nothing need to be don
		return
	}

	jm.mydb = &MyDB{user, pass, host, port, dbname, nil}
	err = jm.mydb.setup()
	if err != nil {
		panic(err)
	}
	return
}
Beispiel #2
0
func NewCrypto() (*MyCrypto, error) {
	u, err := user.Current()
	if err != nil {
		return nil, err
	}
	myConfig, err := config.NewConfig(fmt.Sprintf("%s/.waparc", u.HomeDir))
	if err != nil {
		return nil, err
	}
	return &MyCrypto{key: myConfig.Encryption_key}, nil
}