func SetupDB(dbName string, bucket string) (*Database, error) {
	// Open the db data file in your current directory.
	// It will be created if it doesn't exist.
	db, err := bolt.Open(dbName, 0600, nil)
	if err != nil {
		return nil, err
	}
	// Create the buckets, if they do not exist
	err = db.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists([]byte(bucket))
		if err != nil {
			return err
		}
		log.Printf("Bolt Bucket \"%s\", setup done", bucket)
		return nil
	})
	if err != nil {
		return nil, err
	}
	log.Printf("Bolt Database \"%s\", setup done", dbName)
	return &Database{
		BoltDB: db,
		Bucket: bucket,
	}, nil
}
// SetupDB opens a Bolt Database and creates a Bucket for storing
// key-value pairs.
//
// If the dbName file does not exist it will create it.
SetupDB opens a Bolt Database and creates a Bucket for storing
key-value pairs.

If the dbName file does not exist it will create it.
// SetupDB opens a Bolt Database and creates a Bucket for storing // key - value pairs . // // If the dbName file does not exist it will create it .
func SetupDB(dbName string, bucket string) (*Database, error) {
	db, err := bolt.Open(dbName, 0600, nil)
	if err != nil {
		return nil, err
	}
	err = db.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists([]byte(bucket))
		if err != nil {
			return err
		}
		log.Printf("Bolt Bucket \"%s\", setup done", bucket)
		return nil
	})
	if err != nil {
		return nil, err
	}
	log.Printf("Bolt Database \"%s\", setup done", dbName)
	return &Database{
		BoltDB: db,
		Bucket: bucket,
	}, nil
}
func SetupDB ( dbName string , bucket string ) ( * Database , error ) { db , err := bolt . Open ( dbName , 0600 , nil ) if err != nil { return nil , err } err = db . Update ( func ( tx * bolt . Tx ) error { _ , err := tx . CreateBucketIfNotExists ( [ ] byte ( bucket ) ) if err != nil { return err } log . Printf ( " \" \" " , bucket ) return nil } ) if err != nil { return nil , err } log . Printf ( " \" \" " , dbName ) return & Database { BoltDB : db , Bucket : bucket , } , nil }
SetupDB opens a Bolt Database and creates a Bucket for storing
key-value pairs.
SetupDB opens a Bolt Database and creates a Bucket for storing key - value pairs .
// Open the db data file in your current directory. // It will be created if it doesn't exist. // Create the buckets, if they do not exist